By default, Apache servers look for index.html when a visitor requests a directory (e.g., http://example.com/products). On ruachost.com, you can customize which file loads first by editing the .htaccess file.
Why Change the Default Directory Index?
-
Display a different file (e.g.,
index.phpinstead ofindex.html). -
Use multiple fallback options (e.g.,
home.html,default.php). -
Control how directories behave when no index file exists.
-
Improve flexibility for CMSs or custom applications.
Steps to Change the Directory Index
Step 1: Open the .htaccess File
-
Log in via FTP, SFTP, or File Manager.
-
Navigate to your site’s root directory (
public_html). -
Open or create the
.htaccessfile.
Step 2: Add the DirectoryIndex Directive
Insert the following line:
DirectoryIndex index.php index.html index.htm home.html
-
Apache will look for files in the order listed.
-
In this example, it will first try
index.php, thenindex.html, thenindex.htm, and finallyhome.html.
Step 3: Save and Test
-
Save the
.htaccessfile. -
Visit your site in a browser.
-
Confirm the correct file loads when accessing a directory.
Important Notes
|