htaccess rewrite for query string

This was my solution:

RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]


Try this:

RewriteEngine On
RewriteRule ^(.*)$ /index.php?url=$1 [L]

To a user on your site, they will see and navigate to this:

http://example.com/contact

But the real page would be something like this:

http://example.com/index.php?url=contact

This bit, [L], tells the server that this is the last line of the rewrite rule and to stop.


RewriteCond %{QUERY_STRING} url=(.*)
RewriteRule index.html  %1

(or whatever if it's not index.html, index.php, whatever)

You need to capture the query string, which is not looked at by RewriteRule normally, and use the %1 back reference, not $1 as you would in a capture in a RewriteRule