Index files

A slash (/) at the end of a URL indicates that the URL is pointing to a directory, not a file. If no specific document is identified, most servers display the contents of a default file (or index file). The index file is generally named index.html, but on some servers, it may be named welcome.html or default.html. Often, there is a hierarchy of index file names that the browser checks for and uses the one that has been given the highest priority. For example, if a directory contains both index.html and index.php, the server may be set up to display index.php automatically. This is another small variation you will need to confirm with your server administrator.

Some servers may be configured to display the contents of the directory if an index file is not found, leaving files vulnerable to snooping. For this reason, it is a good idea always to name some page (usually the main page) in each directory index.html (or another specified name). One advantage is that it makes URLs to the index page of each directory more tidy (http://www.littlechair.com rather than http://www.littlechair.com/homepage.html, for example).

Tip

Another variable to confirm with your server administrator is whether your server has been configured to be case sensitive. For case-sensitive servers, the files index.htm and Index.htm are not equivalent, and can result in missing file errors.

Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.