How to Change the Default Directory Page in WHM

Posted on Updated on

When you access a folder on a domain via a browser, the server decides which file to send you based on certain rules. Most of you know that placing a file named “index.html”in the root of a directory will cause it to display its contents if you just type in the name of the directory itself into your URL bar. However, different applications use different filename conventions and sometimes you’d like a little more control over which file is displayed by default. Say for example you have a WordPress installation which uses “index.php” at its base file. Whenever you visit your blog, this is displayed by default whether you actually type in the file name or not.

But what if your directory already has an “index.html” file in it for whatever reason? Or some other one that has a higher priority than index.php? Luckily for us, WHM allows us to create and modify  a hierarchy of filenames which are displayed by default when you access a directory. Let’s look at how to modify this to suit our needs.

Displaying Default Files

To start with, I’m going to access the root folder – public_html – of an empty domain. In this, I’ve created a default file called “index.html” with some basic text and elements.

index html present

Now when I access the domain directly, the contents of this file are displayed in the browser as shown here:

default is index html

So far so good – this behavior is what we expect. Now log into your WHM dashboard and search for the “Apache Configuration” menu item under “Service Configuration”. This will present us with a list of things we can change about our Apache installation. Choose “DirectoryIndex Priority”:

apache configuration

The resulting page will present us with a sorted list of filenames. As you can see below, you have the option to move individual items up and down, higher or lower in the priority. You can also add or delete filenames as per your requirements. The idea is that those filenames which are higher in the list will be shown preferentially as the default file in a directory when none is specified.


We can immediately notice two things – index.html is the third-highest ranking filename whereas something like index.php is way, way down. So if you want the latter to display instead of the former, you have the option to either move index.php up towards the top of the list ahead of index.html, or move index.html down the ranking hierarchy. Of course, you can also delete index.html entirely if you want. It all depends on your purposes for having index.html in your root directory in the first place – is it for testing? Is it part of another application? Do you need it to display by default? Your choice of which option to select while dealing with the problem are contingent on your requirements.

Testing Higher Ranking Files

Let’s see if this index specification is working as intended. In the same empty directory, I’ve created a new file called “index.htm”.

second file with higher priority

You can see from the hierarchy of filenames that it is placed one notch ahead of index.html. This means that with both of these files present in the root directory, index.html should have a higher priority.

Sure enough when I navigate to the root folder for the second time, I see the expected index.htm as opposed to the file we saw earlier:

the new file displayed

Setting Preferences via .htaccess

Finally, you can also use your .htaccess file with the DirectoryIndex parameter to specify a list of default files for that specific directory as opposed to the entire server. Let’s say you have the following command in .htaccess:

DirectoryIndex index.php index.html

This instructs the server that index.php takes precedence over index.html for this specific directory alone. If you don’t have access to WHM because you’re on a shared hosting plan for example, this latter option will solve your problems. If on the other hand, you wish to make server-wide changes as the system administrator, the “DirectoryIndex Priority” option in WHM is the way to go.

Leave a Reply

Your email address will not be published. Required fields are marked *