oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Mo' Betta Indexes
Pages: 1, 2, 3, 4, 5

General Directives

Before we can start fiddling with Apache's generated index pages, we have to be able to view a page that Apache pieces together when we make a request for a folder. If the folder contains a file that is specified in a DirectoryIndex directive, then that file will be served to the client; otherwise Apache will create an auto-index page (as shown in Figure 1).

DirectoryIndex file1 [file2] ... 

This directive specifies a list of files that should be sent to the client when a request is made for a directory's URL. If multiple files are specified, then the first file takes precedence over the second, and so on down the line. index.html (or index.php if you're using PHP) is the prototypical directory index page under Apache.

1.3.x 2.0.x

On the flip side of this coin are files that you don't want to show up in your index pages. Typically files that you wish to ignore are hidden or are temporary files such as those created by your editor (Emacs saves buffers with &~" appended), or files that you don't want visitors to see (such as CVS subdirectories). indexignore">

IndexIgnore pattern [pattern] ...
This directive allows you to specify files that shouldn't be included in directory listings.

1.3.x 2.0.x

So the next step is to create a directory in our server's document tree that will not contain any file specified in the DirectoryIndex directive. To add a little diversity, let's populate our new directory with a sample of different file types so that we will be able to see our icons in action:

A view of our folder through a command-line interface
Figure 2: A CLI view of our folder in OS X's Terminal application.

The first directive we'll look at that alters the display of our generated index page is possibly the simplest and most important -- it controls whether Apache's index pages will contain:

  • Icons serving to visually indicate the type of file.
  • Columns that contain related information about the file (specifically the file's size, description, and the date that it was last modified, as seen in Figure 2).
FancyIndexing on|off | off

The FancyIndexing directive is pretty self-explanatory in nature; on will tell Apache to include the icons and columns in the index page, whereas off will simply generate an unordered list (ul) for the files.

1.3.x 2.0.x

The following image is what you see when FancyIndexing is turned off:

An index page without "fancy indexing"
Figure 3: An example of an index page without "fancy indexing."


The next directive we'll look at can be considered the Swiss Army Knife of Apache's configuration directives — it has so many parameters that can affect virtually every component of an auto-index page. So let's just take a quick look at it, put it in the back burner, and move on to the first major section of our makeover: icons.

IndexOptions option1 [option2] [...]

We'll see what the possible options for this directive can be shortly.

1.3.x 2.0.x

Pages: 1, 2, 3, 4, 5

Next Pagearrow