2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
6 <description>Provides for "trailing slash" redirects and
7 serving directory index files</description>
9 <sourcefile>mod_dir.c</sourcefile>
10 <identifier>dir_module</identifier>
13 <p>The index of a directory can come from one of two sources:</p>
16 <li>A file written by the user, typically called
17 <code>index.html</code>. The <directive module="mod_dir"
18 >DirectoryIndex</directive> directive sets the
19 name of this file. This is controlled by
20 <module>mod_dir</module>.</li>
22 <li>Otherwise, a listing generated by the server. This is
23 provided by <module>mod_autoindex</module>.</li>
25 <p>The two functions are separated so that you can completely
26 remove (or replace) automatic index generation should you want
29 <p>A "trailing slash" redirect is issued when the server
30 receives a request for a URL
31 <code>http://servername/foo/dirname</code> where
32 <code>dirname</code> is a directory. Directories require a
33 trailing slash, so <module>mod_dir</module> issues a redirect to
34 <code>http://servername/foo/dirname/</code>.</p>
38 <name>DirectoryIndex</name>
39 <description>List of resources to look for when the client requests
40 a directory</description>
41 <syntax>DirectoryIndex
42 <var>local-url</var> [<var>local-url</var>] ...</syntax>
43 <default>DirectoryIndex index.html</default>
44 <contextlist><context>server config</context><context>virtual host</context>
45 <context>directory</context><context>.htaccess</context></contextlist>
46 <override>Indexes</override>
49 <p>The <directive>DirectoryIndex</directive> directive sets the
50 list of resources to look for, when the client requests an index
51 of the directory by specifying a / at the end of the a directory
52 name. <var>Local-url</var> is the (%-encoded) URL of a document on
53 the server relative to the requested directory; it is usually the
54 name of a file in the directory. Several URLs may be given, in
55 which case the server will return the first one that it finds. If
56 none of the resources exist and the <code>Indexes</code> option is
57 set, the server will generate its own listing of the
60 <example><title>Example</title>
61 DirectoryIndex index.html
64 <p>then a request for <code>http://myserver/docs/</code> would
65 return <code>http://myserver/docs/index.html</code> if it
66 exists, or would list the directory if it did not.</p>
68 <p>Note that the documents do not need to be relative to the
72 DirectoryIndex index.html index.txt /cgi-bin/index.pl
75 <p>would cause the CGI script <code>/cgi-bin/index.pl</code> to be
76 executed if neither <code>index.html</code> or <code>index.txt</code>
77 existed in a directory.</p>