I'm trying to rewrite the following URL, and the rewrite seems to work, but doesn;t forward to the rewritten page. From: domain.com/index.php?random To: domain.com/random RewriteRule ^random$ /index.php?random [L] Code (markup): With this rewrite in place, I can visit both the From and To URL. I want the From URL to automatically redirect to the To domain (i.e., a user will never see index.php?random in their browser location). What am I doing wrong here?
This will solved your problem overly: RewriteEngine on RewriteRule ^/?([^/]+)$ /index.php?$1 [L] RewriteCond %{QUERY_STRING} !\= RewriteCond %{QUERY_STRING} ^(.+)$ RewriteRule ^/?index.php$ /%1 [R,L] Code (markup): This will work even on "/index.php?anything" or "/index.php?whatever".