Skip to content Skip to site navigation

Fancy Indexing

When pointed at a directory, this server looks for an index file called index.html, index.html.var, index.shtml, or index.htm, in that order. The server sends back to the browser the first index file that is found. If it's pointed at a directory that doesn't have an index file, the server will perform "fancy indexing" and return the following page:

  • Set the title and main header to "Index of dir"
  • The header file (HEADER.html) for this directory, if any
  • A list of the files in this directory
    • Each file name is a link to the file
    • The first file is "Parent Directory"
    • Last modification date, size, and an icon indicating the type of file are included
  • The readme file (README.html for this directory, if any

Why use indexing?

Indexing is typically used to make a set of files available to the browser. Of course, you could just provide index.html. But you may have a large number of files in your directory, and writing your own index would be time-consuming. Also, one advantage of directory indexing is that it's done on-the-fly. If you have a directory whose contents change often, you probably don't want to keep updating index.html. Directory indexing will list the contents of the directory when the request is made.

How to use fancy indexing

Actually, you don't have to do anything and the server will return a list of your files formatted as above. If you just want people to be able to get at your files, that will work fine. However, if you want to provide some context for the user, you should probably include header and/or readme files. Those files should be named HEADER.html and README.html, and reside in the directory that you want indexed.

In the header file (HEADER.html), you can set both the <TITLE> and <H1> elements to provide a more meaningful description of the directory.

The readme file (README.html) is a good place to give an overview of the files in your directory.

Last modified April 26, 2010