I have the following line:
RewriteRule ^page.php?var1=([0-9]+)&var2=(.*)&var3=(.*)$ index.php?module=page&var1=$1
When I visit the directory with this url: page.php?var1=24&var2=346adf&var3=asdf
It doesnt do the regexp. Anyone having a clue?
Basically your rule is incorrect. Reason: You can only match REQUEST_URI using RewriteRule
but cannot match QUERY String in there.
Change your code to this to make it correct:
RewriteCond %{QUERY_STRING} ^var1=([0-9]+)&var2=[^&]*&var3=.*$ [NC]
RewriteRule ^page\.php/?$ index.php?module=page&var1=%1 [L,NC,QSA]
The first thing I notice is that the ? should probably be escaped.
Besides missing escapes, query string (the stuff after ?
) is not part of the RewriteRule
matching.
You have to use an additional RewriteCond
if you want to match on the query string.
For example:
RewriteCond %{QUERY_STRING} ^foo=([^&]+)&bar$
RewriteRule ^page\.php$ otherpage.php?x=%1 [QSA]
I wouldn't recommend this tho. You are better off parsing the query string in your scripts.