My url is
http://localhost/site.in/names-in.php?loc=kochi
My required url is
http://localhost/site.in/names-in/kochi
I have this in .htaccess
which unfortunately not working.
Options +FollowSymLinks
RewriteEngine on
RewriteRule names-in/(.*)/ names-in.php?loc=$1
I have this in page print_r($_GET);
which shows empty array. Any inputs why its not working?
2
Answers
Try this
you can access from http://localhost/site.in/names-in/kochi
Your original RewriteRule is not being met. You can achieve this using
{QUERY_STRING}
instead:Then to internally rewrite the URL:
Make sure you clear your cache before testing this. This is using
R=301
which is a permanent redirection, I advise you change this toR=302
while testing, as this is temporary.I’ve also added
?
onto the end of the rewritten URL. This is to stop the original query appearing on the end of the URL.