Change the Default Index Page Using .htaccess

By default most servers that host websites are configured to use a file called index.code-type (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:

 

 

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:

 

 

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.


Share:

Leave a Reply