301 Redirect index.php or index.html to your main domain


Simply enter the following code into your .htaccess file (changing the addresses in the examples below as needed) and save the changes. If there are several individual pages which have moved, just repeat as neccesary. Not sure how to access or change or .htaccess file. Read our .htaccess guide here.

 

301 Redirect from /index.php to example.com/

Options +FollowSymLinks
RewriteEngine on
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

(the above code will also redirect redirect example.com/foldername/index.php to example.com/foldername/ )

Benefits of redirecting traffic from index.php or index.html to your domain homepage
  • Helps to keep your address bar URLs looking clean and consistent, and also to avoid duplicate content penalities from search engines, and issues associated with having links pointing both to example.com/index.php and also to example.com/.