I'm using Apache2 and mod_rewrite to hide my 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 (as per the last rule)
From there, the RewriteCond and RewriteRule should kick in and redirect me to /search/test, right? From what I understand the %1 in my first RewriteRule corresponds to the (.*) in the RewriteCond which should contain test.
However, what actually happens is I'm redirected to /search/test/?query=test. So, the rule works, but for some reason the query string appended. Is it the QSA option being automatically added somehow/somewhere?
I'm then stuck in an infinite loop of redirecting to /search/test?query=test because the first RewriteCond and RewriteRule kick in again, and again, and again...
What am I doing wrong?!
Thanks!