How to change the default index page in .htaccess

The web server will look for specifically named files as the first page of your website when you go to yourdomain.com. Typically the file is named index and then it will have an extension on the end such as .html or .php. Our servers by the default will look for the following files: index.html, index.htm, index.php and default.htm. 

Although you are able to change this if you wish to have the file name called something else such as home.html for example. All you need to do is make a simple adjustment in the .htaccess file. 

1. Log into your cPanel Account

2. Locate the "Files" category and click on the "File Manager" icon.

3. Click on "Settings" in the top right hand corner

4. Make sure the document root for the domain name you have been working on is set correctly. Then make sure the box for "Show Hidden Files" is checked. It needs to have a tick in the box. Then click on the "Save" button.

5. Locate the .htaccess file and right click on it - Then select the "Edit" option. 

6. You should now be in the text editor - You will need to insert the following code into the .htaccess file:

#Alternate default index pages
DirectoryIndex home.html index.htm index.html index.php

As you can see home.html is now on the list of DirectoryIndex. Once the file has been saved, the server will look for home.html and load that instead of loading any other index file. Alternatively, if you did not want it look for any index.htm/index.html/index.php files then you can simply use this piece of code below.

#Alternate default index page
DirectoryIndex home.html

7. Once you are happy with the code you have entered into your .htaccess file - Click the "Save Changes" button. 

If you are having issues with the above or need further assistance. Please raise a support ticket through the clients portal. 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to force www or non-www in your .htaccess file in cPanel

This guide will show you how to force your website to either use www or non-www when visitors...