Rewrites work except this one line


I’ve been using mod_rewrite for a few months now, but am by no means an expert. Everything in my .htaccess file works except this line:

RewriteRule ^foo\.php\?param1=1955&param2=5&param3=25&param4=%25&param5=%25&param6=&param7=500&param8=Search&param9=basic&param10=1&param11=1 [R=301,L]

Even if I strip the file down to just that line to eliminate conflicts and then add this line to make sure rewrites actually work:

RewriteRule ^foo2\.php [R=301,L]

the 2nd line works as expected, but the 1st still doesn’t.

I should note that I can’t really use a pattern for the first line because there will be dozens of similar urls in various formats that I’ll need to rewrite to its own different url. In any case, I can’t figure out why the first line doesn’t work. Any ideas?


Hi un!

The problem is that you are not aware (yet) that the RewriteRule statement can only examine the {REQUEST_URI} variable (you are trying to match the {QUERY_STRING} variable as well as the {REQUEST_URI} AND the reserved character which separates the two but is part of neither).

In other words, I will agree with your statement about non-expert. Please have a read of the tutorial linked in my signature for more information. It’s helped a LOT of members and, with the sample codes, it should help you, too.