httpd-wiki-changes mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Httpd Wiki] Update of "Recipes/DirectoryListings" by slive
Date Tue, 07 Nov 2006 01:49:04 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.

The following page has been changed by slive:

New page:
= Directory Listing Configuration =

Here we describe various types of things that the server can send when you request a directory
rather than an individual file.

== Trailing Slash Redirection ==

If you request a directory without including the trailing slash in its name (i.e. {{{}}}
rather than {{{}}}), then Apache must send a redirect to add the trailing
slash to the URL.  This is necessary so relative hyperlinks will work in the resulting file.

For this to work, Apache must know the name of the server so that it can send a redirect back
to itself.  Normally, when [
UseCanonicalName] is set off, the name supplied by the client in the {{{Host}}} HTTP request
header is used.  If {{{UseCanonicalName}}} is on, then you need to assure that [
ServerName] is set correctly in order for this redirect to work.

== Directory Indexes ==

When a directory is requested, Apache may be configured to send a particular file within that
directory automatically.  This is configured with the [
DirectoryIndex] directive.  It can list one or more files that Apache should search for in
the directory, with the first existing file being returned to the client.  For example:

DirectoryIndex index.html index.htm index.php welcome.html

== Directory Listings ==

If no file from the DirectoryIndex directive can be located in the directory, then [
mod_autoindex] can generate a listing of the directory contents.  This is turned on and off
using the [ Options] directive.  For
example, to turn on directory listings for a particular directory, you can use

<Directory /usr/local/apache2/htdocs/listme>
  Options +Indexes

To prevent directory listings (for security purposes, for example), you should remove the
{{{Indexes}}} keyword from every Options directive in your configuration file.  Or to prevent
them only for a single directory, you can use

<Directory /usr/local/apache2/htdocs/dontlistme>
  Options -Indexes

=== Excluding Files ===

If you would like listings to be enabled, but you want to omit particular files, you can use
the [ IndexIgnore] directive.
 For example, to omit any filename starting with {{{tmp}}} and also the parent directory link
(..), you could use

IndexIgnore tmp* ..

=== Headers and Footers ===

The directives [ HeaderName]
and [ ReadmeName] configure
a file to be included, respectively, above and below the file listing.  If no path is given,
Apache will look for these files in the directory being listed.  For example:

HeaderName header.html
ReadmeName footer.html

A path starting in slash can be used if you want the same files included for all directories:

HeaderName /site/header.html
ReadmeName /site/footer.,html

=== Styling the listing ===

The directory listing is highly configurable.  The [
IndexOptions] directive gives lots of choices for different configurations and the [
IndexStyleSheet] directive allows a CSS stylesheet to be specified.  A typical configuration
might look like:

IndexOptions FancyIndexing HTMLTable
IndexStyleSheet /css/autoindex.css

=== Extended example ===

For a more complete example, including a configuration for the icons displayed with the files,
see {{{conf/extra/httpd-autoindex.conf}}} as distributed with Apache httpd.

View raw message