Apr

20

When a surfer accesses your website, the server checks the root folder for an index file. Some examples of common index files are: index.html, index.htm, index.php, index.cgi, index.pl. The supported index files depend on the how the server is set up.

Your default web hosting server might be set to:

DirectoryIndex index.html index.shtml index.php index.htm default.html Default.htm default.html Default.html default.shtml Default.shtml page1.html index.pl index.cgi index.php3 index.phtml home.htm home.html home.shtml index.wml

As long as you name your “index” file any one of those things, it will work!

If you have two files with names from that list, Apache will show the one that shows up first (e.g. index.htm will show up, even if you have an index.php file in the same directory).

You can change your own DirectoryIndex setting to be anything you’d like via an .htaccess file too!

If the server cannot find an index file, it will try to display an index of all the files within the current directory, however if this is disabled, the server will end up displaying a 403 forbidden error. Using .htaccess, you can use a completely different index file instead of the defaults set by your server host (if you are using a hosting plan). To do this, insert the following line into an .htaccess file:

DirectoryIndex pagename.html second-choice.html third-choice.php


Change pagename.html, second-choice.html third-choice.php to the page that you would like to use as the index file.

Hope this helps!



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

2 Comments so far

  1. Harjit Singh Ubhi on April 21, 2008 4:02 am

    How does one create .htaccess and .htpasswd on Linux Terminal without accessing 3rd party sites who help in generating encrypted passwords

    Harjit Singh Ubhi

  2. admin on April 21, 2008 9:10 am

    Hi, Harjit Singh Ubhi

    If you have shell access, run the following command:

    /usr/bin/htpasswd -c ~/.htpasswd USERNAME

    Replace USERNAME with the username of the user you wish to add (such as Patrick). You’ll be prompted to enter a password for the user. Just type any password you want, hit enter. The password will be automatically encrypted.

Sponsors




Links