http:// domain.com/index.php -> http:// domain.com/ - OK
http:// domain.com/index.php?z=abc -> http:// domain.com/index.php?z=abc - not OK, stays the same. This works using the code below:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
How to modify this code so that
http:// domain.com/index.php?z=abc -> http:// domain.com/?z=abc
Try the modified RewriteCond below
Apache will take care of the query string automatically. All you need is this: