Hostwinds Tutorials

Search results for:


Table of Contents


How To Change the Default Index Page

Change the Default Index Page Using .htaccess

How To Change the Default Index Page

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 a .htaccess file or are not certain how to edit this file, please refer to our guide: Creating and editing a .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 wish to replace:

#Tells the server to serve an alternate index page
DirectoryIndex new-creative-filename-here.html

Example:

#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 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.

Written by Michael Brower  /  June 22, 2017

Need help? Chat now!