frankie frankie - 8 months ago 56
Apache Configuration Question

.htaccess redirect from index.php not working

I did my best to search in stack overflow questions and answers and even when I tried to apply a solution, it is not working.

I need to redirect all adresses, that begin with


This is what I try:

RewriteCond %{HTTP_HOST} ^www.example\.com [NC]
RewriteRule ^(index\.php\?lang\=)$$1 [L,R=302]

The location /index.php?lang=en is not redirecting /en (anywhere).
It is at the same URL.


You can't match a query_string in a rewriterule. You need a specific RewriteCond for it. It should be more or less like this:

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteCond %{QUERY_STRING} ^lang=(.*)
RewriteRule ^ [R=302,L,QSD]