How to Change the Directory Index File (Home/Default File)
How to Change the Directory Index File (Home/Default File)
Category: Tools & Settings
Understanding Directory Index Files
By default, our servers recognize index.php and index.html as the main index files for your website. When a visitor accesses your domain, the server checks for these files in the order mentioned. If neither is found, a directory listing is displayed.
Changing the Default Index File
To set a different file, like home.html, as your default, you will need to modify the directory index file using the .htaccess file.
Option 1: Creating an .htaccess File Manually
Follow these steps to create or edit the .htaccess file manually:
- Navigate to Files > File Manager in your Web Hosting Control Panel.
- Locate your domain's root folder (usually
/www/mydomain.com/). - If there is no
.htaccessfile, create a new file called.htaccess. - Edit the
.htaccessfile and insert the following line:
DirectoryIndex main.html
This code instructs the server to prioritize main.html as the default index file. If it's absent, the server will fall back to index.php or index.html.
Important Note
All directives in the .htaccess file apply to the directory where the file resides and all its subdirectories, meaning it works recursively.
Option 2: Using the .htaccess Generator
If you prefer a simpler method, you can use the .htaccess Generator tool:
- Go to the Advanced menu and select .htaccess Generator.
- Choose the main folder of your domain by clicking on "Browse."
- Check the box for "Default index page" and type
main.html. - Click on the Generate button.
- Review the content, which includes your selected options along with the Directory index file.
- Finally, click Save .htaccess to create the file in the designated folder.
Tags: .htaccess, change directory index file, default homepage, DirectoryIndex, web hosting control panel, website settings