Friday, 15 November 2013

htaccess Redirect index.php to root



RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L] 

You can replace second line with this
RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,NC,L]


It redirects URIs ending with index.php, index.htm or index.html to /. Works with subdirectories, too.

Also, notice the NC flag. It makes it case-insensitive. So it works even if the URI is in upper-case such asINDEX.PHP.
 


Share:

No comments:

Post a Comment