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.

Ivar
  • 4,344
  • 6
  • 38
  • 53

1 Answers1

1

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]
Community
  • 1
  • 1
Gumbo
  • 643,351
  • 109
  • 780
  • 844