Computing: Website and Database Applications

Web/DB Home   Home   Contact

Webserver directory listing.

1. Directory listing on Apache webservers.
  1.1. Accessing directories on a webserver.
The information on this page concerns the Apache webserver, an open-source multi-platform webserver solution distributed by The Apache Software Foundation. For other webservers, please have a look at those programs' documentation.
If a browser tries to access a directory without specifying a particular filename, Apache looks up this directory for particular files, defined in the DirectoryIndex directive. A common example of this directive is:
    DirectoryIndex index.php index.html
In this case, if index.php exists, it is served; otherwise index.html is sent to the webbrowser. But, what happens if neither of the files mentioned in the DirectoryIndex directive exists?
Two possibilities:
    • If 'Indexes' is part of the keywords in the Options directive, Apache displays the directory's content (as a rudimentary listing).
    • If there is no 'Indexes' option for this directory (e.g. for cgi-bin, that the web user must not be able to access), an error 403 (Forbidden) is generated.
Example of an Options directive:
    Options Indexes FollowSymLinks
  1.2. Fancy indexing.
The default directory listing returned by Apache is really rudimentary and far away from pretty. However, there is a standard Apache module called "fancy indexing", switched on by the directive:
    IndexOptions FancyIndexing
With fancy indexing active, a whole set of new directives becomes available, allowing server-generated directory listings with header and footer, file sorting, file-type specific icons and descriptions, etc. For information about this feature, have a look at the Apache manual or search the Internet for "Apache fancy indexing".
  1.3. Alternatives.
Instead of using the Apache build-in features, it is of course possible to use your own scripts in order to list your directories exactly the way you want to. If you search the Internet, you'll find lots of personalized solutions (mostly using PHP) for listing your files, some very simple, others complete applications; in the next chapter, I describe my scripts, as used to list the content of the Lazarus/Free Pascal download directories on this website.