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.
if you're using PHP)
is the prototypical directory index page under Apache.
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">
This directive allows you to specify files that shouldn't be included in directory listings.
IndexIgnore pattern [pattern] ...
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:
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
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.