mod_dir.html revision 4ed1b0d51faaa03eab8a00036dd0f7a829811adc
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Apache module mod_dir</TITLE>
</HEAD>
<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#000080"
ALINK="#FF0000"
>
<!--#include virtual="header.html" -->
<H1 ALIGN="CENTER">Module mod_dir</H1>
This module is contained in the <code>mod_dir.c</code> file, and
is compiled in by default. It provides for "trailing slash" redirects and
serving directory index files.
<h2>Summary</h2>
The index of a directory can come from one of two sources:
<ul>
<li>A file written by the user, typically called <code>index.html</code>.
The <A HREF="#directoryindex">DirectoryIndex</A> directive sets
the name of this file.
This is controlled by <code>mod_dir</code>.
<li>Otherwise, a listing generated by the server. This is provided by
<a href="mod_autoindex.html"><code>mod_autoindex</code></a>.
</ul>
The two functions are separated so that you can completely remove
(or replace) automatic index generation should you want to.
<p>A "trailing slash" redirect is issued when the server receives a
request for a URL <SAMP>http://servername/foo/dirname</SAMP> where
<SAMP>dirname</SAMP> is a directory. Directories require a trailing
slash, so <code>mod_dir</code> issues a redirect to
<SAMP>http://servername/foo/dirname/</SAMP>.
<h2>Directives</h2>
<menu>
<li><A HREF="#directoryindex">DirectoryIndex</A>
</menu>
<hr>
<A name="directoryindex"><h2>DirectoryIndex</h2></A>
<!--%plaintext &lt;?INDEX {\tt DirectoryIndex} directive&gt; -->
<strong>Syntax:</strong> DirectoryIndex <em>local-url local-url ...</em><br>
<strong>Default:</strong> <code>DirectoryIndex index.html</code><br>
<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<Strong>Override:</strong> Indexes<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_dir<p>
The DirectoryIndex directive sets the list of resources to look for,
when the client requests an index of the directory by specifying a /
at the end of the a directory name. <em>Local-url</em> is the
(%-encoded) URL of a document on the server relative to the requested
directory; it is usually the name of a file in the directory. Several
URLs may be given, in which case the server will return the first one
that it finds. If none of the resources exist and the
<CODE>Indexes</CODE> option is set, the server will generate its own
listing of the directory.
<P>
Example:
<blockquote><code>
DirectoryIndex index.html
</code></blockquote>
then a request for <code>http://myserver/docs/</code> would return
<code>http://myserver/docs/index.html</code> if it exists, or would list
the directory if it did not. <p>
Note that the documents do not need to be relative to the directory;
<blockquote><code>
DirectoryIndex index.html index.txt /cgi-bin/index.pl</code></blockquote>
would cause the CGI script <code>/cgi-bin/index.pl</code> to be executed
if neither <code>index.html</code> or <code>index.txt</code> existed in
a directory.<p><hr>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>