I use Apache2 and mod_rewrite to hide query strings. These are the rules in question.
RewriteCond %{QUERY_STRING} ^query=(.*)$ RewriteRule (.*) /search/%1 [R=301,L] RewriteRule ^search\/?$ /search/?query=test [R=301,L]
When I visit /search (or /search/ ), I am correctly redirected to /search/?query=test (according to the last rule)
From there, RewriteCond and RewriteRule should click and redirect me to /search/test , right? From what I understand, %1 in my first RewriteRule matches (.*) In the RewriteCond , which should contain test .
However, what is actually happening, I am redirected to /search/test/?query=test . So the rule works, but for some reason the query string is added. Is the QSA parameter automatically added somehow / somewhere?
Then I got stuck in an infinite redirect loop to /search/test?query=test , because the first RewriteCond and RewriteRule turn on again, and again, and again ...
What am I doing wrong?!
Thanks!
source share