Thursday, May 2, 2013

How to change Alternative Index Files with htaccess file

When a visitor accesses your website, the server checks the folder for an index file. Some examples of common index files are: index.htm, index.html, index.php, index.cgi, The supported index files depend on the how the server is set up. DreamHost's servers are set to:
DirectoryIndex index.html index.shtml index.htm Index.html Index.htm Index.shtml default.htm Default.htm default.html Default.html default.shtml Default.shtml page1.html index.cgi index.php index.php3 index.phtml home.htm home.html home.shtml index.wml quickstart.html
As long as you name your "index" file any one of those things, it will work! Note that when you add a new domain or sub-domain to your account, if you add no index file, DreamHost creates quickstart.html for you and places it in your directory so that will show up by default unless you delete it or add your own index file. If you have two files with names from that list, Apache will show the one that shows up first (e.g. index.html will show up, even if you have an index.php file in the same directory). You can change your own DirectoryIndex setting to be anything you'd like via an .htaccess file too! If the server cannot find an index file, it will try to display an index of all the files within the current directory, however if this is disabled, the server will end up displaying a 403 forbidden error. Using .htaccess, you can use a completely different index file instead of the defaults listed above. To do this, insert the following line into an .htaccess file:
DirectoryIndex pagename.html
Change pagename.html to the page that you would like to use as the index file.
Disqus Comments