site.com/link?p=2
give $_GET['p']==2 even though i've already made
site.com/link
rewrite to
site.com/index.php?page=link
So, i'm trying to replace site.com/link?p=2 with site.com/link&p=2
RewriteEngine on
RewriteRule (.*)\?(.*) $1\&$2
RewriteCond %{REQUEST_URI} !\....$
RewriteRule ^(.*)$ /index.php?p=$1
It doesn't work!
RewriteRule
cannot see query strings (the ?
and anything after it) on the left-hand side; it matches only on the path part of the URL.
But the good news is, all you probably need to do is this:
RewriteEngine on
RewriteCond %{REQUEST_URI} !\....$
RewriteRule ^(.*)$ /index.php?p=$1 [QSA]
The QSA
option, Query String Add, tells your RewriteRule to add to the query string instead of replacing it (the default behavior, which doubtless prompted the whole issue).