views:

13

answers:

1

This is the first time I use mod_rewrite and I can't get it to work. I have a website with bands and their IDs. What I want:

a URL /bands/My_Band_id13/ should redirect to /bands/index.php?bandname=My_Band&bandID=13

What I have:

RewriteRule ^/bands/(.*)_id(.*)/$ /bands/index.php?bandname=$1&bandID=$2

What am I doing wrong?

A: 

try adding the 'qsappend|QSA' (query string append) rewrite flag to your rule, ie.

RewriteRule ^/bands/(.*)_id(.*)/$ /bands/index.php?bandname=$1&bandID=$2 [QSA]

UPDATE: also, try removing / outcommenting your RewriteBase /. if this doesn't work, neither, try moving your .htaccess file into the same directory your index.php is in and adapt the RewriteRule, eg.

RewriteRule ^(.*)_id(.*)/$ index.php?bandname=$1&bandID=$2 [QSA]
ax
I'm afraid that did not change anything.
Maenny
What I noticed, though is that the redirects work only for the root folder. I thought that the .htaccess rules extend on every subfolder. Is that not true?
Maenny
can you try enabling rewrite logging, http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog , with a `RewriteLogLevel` >= 3, and post the log here? thanks!
ax
Hope you're looking for this:www.metaldemos.com78.35.88.57 - - [11/May/2010:17:20:12 +0200] "GET /bands/Kriegskarthaun_id12/ HTTP/1.1" 403 296 "-"
Maenny
.htaccess file rules *are* propagated to subfolders , see httpd.apache.org/docs/2.2/howto/htaccess.html . they might be masked by other configuration directives, though.
ax
no, that's *not* what i am looking for. that's from the access log - i'm looking for the rewrite log, and i posted a link to how to enable it. you need access to the main server or virtualhost config, though - do you have this?
ax
Maenny
yeah, what i just said (edited into my answer) :)
ax
Thanks a lot :-)
Maenny