By default most servers that host websites are configured to use a file called index (.html/.htm/.php/etc) as the default index page for a website. However, by using some .htaccess code you can change this so that you can name your default index page to whatever you want. The focus of this article is to show you how to do just that! If you have not already created an .htaccess file or you’re not certain how to edit this file, please refer to our guide: Creating and editing an .htaccess file. Let the custom index naming commence!
How To Change the Default index Page
Essentially this rule instructs the server to search for a file other than your normal index file (e.g. index.php) and serve it as the default directory index. It is important to note that the .htaccess file with this rule in it must exist in the same directory as the index file that you’re wishing to replace:
#Tells the server to serve an alternate index page DirectoryIndex new-creative-filename-here.html
#Tells the server to serve an alternate index page DirectoryIndex index.php
This rule is slightly different and instructs the server to scan the directory the .htaccess file is in for a list of files that are defined in the rule. It will then serve the first match it encounters. Please note that the list is read from left to right:
#Tells the server to serve the first match from the list as the default index page DirectoryIndex new-creative-filename-here.html index.php index.cgi new-creative-filename2.htm
This neat little trick not only allows you to be a bit more creative, but can also help you organize different sections of your site. For example, let’s say your site uses PHP and has a FAQ and Downloads section you could name their index files faq.php and downloads.php respectively.