Skip to Navigation

Home -> Articles & Tutorials -> .htaccess -> Default Directory Pages

Tutorial -:- Default Directory Pages -

Some of you may be wondering what a DirectoryIndex is? Well, simply put, this is a command which allows you to specify a file that is to be loaded as your default page whenever a directory or url request comes in, that does not specify a specific page.

Tired of having yoursite.com/ come up when you go to yoursite.com?
Want to change it to be yoursite.com/hello.htm that comes up instead? No problem!

DirectoryIndex filename.htm

This would cause filename.htm to be treated as your default page, or default directory page. You can also append other filenames to it. You may want to have certain directories use a script as a default page. That's no problem too!

DirectoryIndex filename.htm index.cgi index.pl default.htm

Placing the above command in your htaccess file will cause this to happen: When a user types in yoursite.com, your site will look for filename.htm in your root directory (or any directory if you specify this in the global htaccess), and if it finds it, it will load that page as the default page. If it does not find filename.htm, it will then look for index.cgi; if it finds that one, it will load it, if not, it will look for index.pl and the whole process repeats until it finds a file it can use. Basically, the list of files is read from left to right.

Or I could just stick in an htaccess redirect page, which is our next topic!

And on we go...