How do I remove index.php from my URLs?

To remove index.php from the URL, and to redirect the visitor to the non-index.php version of the page

RewriteBase /
RewriteCond %{THE_REQUEST} ^GET.*index.php [NC]
RewriteRule (.*?)index.php/*(.*) /$1$2 [R=301,NE,L]
This will cleanly redirect /index.php/myblog to simply /myblog.

Using a 301 redirect will preserve Google search engine rankings.

Code to remove index.html from URL

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} /index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]

Leave a Reply