views:

48

answers:

1

I get a 404 error page when I try the following rule in htaccess:

RewriteRule ^Test\?service=(.*) test.php?foo=$1 [NC,L]

How come?

I know it's preferable to use something like ^Test/(.*) test.php?foo=$1 [NC,L] instead, but in this case I'd rather like it the way I stated.

Thank you in advance.

+1  A: 

RewriteRule does only check the URL path. But the query (the part from the first ? up to the first #) is not part of the URL path. That can only be checked with the RewriteCond directive:

RewriteCond %{QUERY_STRING} ^service=(.*)
RewriteRule ^Test$ test.php?foo=%1 [NC,L]
Gumbo
Ah okay - it's working now, thanks alot!
Ivarska
By the way, how do I append multiple parameters?
Ivarska
@Ivarska: Can you give an example?
Gumbo
Ivarska
Set the QSA flag and the original query is appended to the new one.
Gumbo