summaryrefslogtreecommitdiff
path: root/docs/manual/mod/mod_dir.html
blob: f150aa2e114e6348259cd9b12eda37d32d9704f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!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>

<H2><A NAME="directoryindex">DirectoryIndex</A></H2>
<!--%plaintext &lt;?INDEX {\tt DirectoryIndex} directive&gt; -->
<A
 HREF="directive-dict.html#Syntax"
 REL="Help"
><STRONG>Syntax:</STRONG></A> DirectoryIndex <EM>local-url local-url ...</EM><BR>
<A
 HREF="directive-dict.html#Default"
 REL="Help"
><STRONG>Default:</STRONG></A> <CODE>DirectoryIndex index.html</CODE><BR>
<A
 HREF="directive-dict.html#Context"
 REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
<A
 HREF="directive-dict.html#Override"
 REL="Help"
><STRONG>Override:</STRONG></A> Indexes<BR>
<A
 HREF="directive-dict.html#Status"
 REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
 HREF="directive-dict.html#Module"
 REL="Help"
><STRONG>Module:</STRONG></A> 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>