1. Knowledge Base
  2. >
  3. Results
  4. >
  5. Directory Index

Directory Index

 

cPanel

This is a .htaccess code that allows you to specify the file which loads as your default page whenever anyone types your domain name.

If you type http://www.hostgator.com in your browser's address bar, the page that loads is index.shtml. You can test this by typing http://www.hostgator.com/index.shtml and noticing that you get the same result.

Tired of seeing the index.html file when you go to http://yoursite.com? Want to see home.html or index.php instead? No problem!

What to do first

  1. Log in to cPanel.
  2. Navigate to the Files section, then click on the File Manager icon.

    HostGator cPanel Files File Manager


    If you want to upload files quicker and have more options and control, we recommend using an FTP Program.
     
  3. Navigate to your public_html folder and edit or create a file named .htaccess.
    Please see the How to Edit Your .htaccess File article for detailed instructions.
  4. Insert the code as described below.

Code format

DirectoryIndex filename.ext 

This would cause filename.ext to be treated as your default page. You can also append other filenames to it. You may want to have each folder without a filename.ext to use a different page name as the default page. That's no problem too.

DirectoryIndex home.html index.php index.shtml page1.php 

Placing the above code in your .htaccess file will cause this to happen. When a user types in yoursite.com, your site looks for home.html in your root directory, finds it, and loads it as the default page. If it does not find home.html, it will then look for index.php; if it finds that one, it will load it; if not, it will look for index.shtml, and the whole process repeats until it finds a file it can use. The list of files is read from left to right.

The .htaccess file is recursive, affecting all the subfolders that do not have their .htaccess file.

Where do I put this code for an addon or subdomain?

Instead of creating and editing the .htaccess file inside public_html, do this inside the document root folder of your addon or subdomain name.

Related Article