I'd written this code for 301 redirect
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
It is working well in case if I do visit my site as http://mysite.com/index.php
, it redirects me to http://mysite.com
But on my localhost
if I try to visit index.php
as localhost/mysite/index.php
it redirects me to localhost
.
How could I solve this problem? Is the code written above is correct?