The Cavitand Site
Free Resources for a Free Internet
Home -> Documentation Projects | Tools | Docs | About

Why to use index files


Many webmasters don't bother to create an index file for each one of their directories. We'll study here why this is a big error that can lead to many problems.

What is an index file?

Websites store their documents in directories. Each document can have its own name, and extension (to represent the type of file: .jpg, .gif for graphics, .txt for simple text files...)

An index file is simply a file called index and usually having a .html extension (this can vary depending on your webserver settings). The index.html is the first one a webserver tries to find in a directory if no other file is specified. For example, when you first access the a website (www.cavitand.com for example), the webserver tries to fetch the index.html file. If it doesn't exist, the server tries to retrieve different index files (index.shtml, index.htm, ...)

What happens if there is no index file in a directory?

The webserver then displays ALL the files placed in that directory. More precisely, it displays the names of all the files in that directory.

Why is that a problem?

All the contents of your directories are shown to everyone. Unless you are very tidy, you will always leave test files around. And files you don't want anyone to have access to. Often, these "secret" files allow an intruder to gather more information about the structure of your site, to access to hidden scripts and documents, and to peruse files they should not be reading.

By using index files, you block access to that contents, just allowing visitors to see the files you want to show.

What should I place in a index file?

That is really up to you and to your site focus. Check any of the directories of the cavitand site to see examples of content to be placed on index files. Of course, they can be empty, effectively stopping peruse of your directories' content.

In several sites, index files point to the contents you want to offer in that directory, leaving out hidden or test files you don't want to release.

Don't forget it: a simple index file can save many headaches.


cavitand.com © 2002
Contact WebMaster
All rights reserved