Hide index.html from URL in address bar

Question: I want users to my site to always go to the base URL http://site.com/ – I never want the index page to show. For example, I want http://site.com/index.html to redirect automatically to http://site.com without the index.html

Answer:

Create a .htaccess file (or add to your existing .htaccess) in the top level directory for your site and add the following line:


RewriteEngine on

RewriteRule ^index\.html$ / [R=301,L]

The line :


RewriteEngine on

may already be in your existing .htaccess. If so, do not duplicate it.