]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_dir.xml
a few new translations and up-to-date patches
[apache] / docs / manual / mod / mod_dir.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $Revision: 1.12 $ -->
5
6 <!--
7  Copyright 2002-2004 The Apache Software Foundation
8
9  Licensed under the Apache License, Version 2.0 (the "License");
10  you may not use this file except in compliance with the License.
11  You may obtain a copy of the License at
12
13      http://www.apache.org/licenses/LICENSE-2.0
14
15  Unless required by applicable law or agreed to in writing, software
16  distributed under the License is distributed on an "AS IS" BASIS,
17  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  See the License for the specific language governing permissions and
19  limitations under the License.
20 -->
21
22 <modulesynopsis metafile="mod_dir.xml.meta">
23 <name>mod_dir</name>
24 <description>Provides for "trailing slash" redirects and
25     serving directory index files</description>
26 <status>Base</status>
27 <sourcefile>mod_dir.c</sourcefile>
28 <identifier>dir_module</identifier>
29
30 <summary>
31     <p>The index of a directory can come from one of two sources:</p>
32
33     <ul>
34       <li>A file written by the user, typically called
35       <code>index.html</code>. The <directive module="mod_dir"
36       >DirectoryIndex</directive> directive sets the
37       name of this file. This is controlled by
38       <module>mod_dir</module>.</li>
39
40       <li>Otherwise, a listing generated by the server. This is
41       provided by <module>mod_autoindex</module>.</li>
42     </ul>
43     <p>The two functions are separated so that you can completely
44     remove (or replace) automatic index generation should you want
45     to.</p> 
46
47     <p>A "trailing slash" redirect is issued when the server
48     receives a request for a URL
49     <code>http://servername/foo/dirname</code> where
50     <code>dirname</code> is a directory. Directories require a
51     trailing slash, so <module>mod_dir</module> issues a redirect to
52     <code>http://servername/foo/dirname/</code>.</p>
53 </summary>
54
55 <directivesynopsis>
56 <name>DirectoryIndex</name>
57 <description>List of resources to look for when the client requests
58 a directory</description>
59 <syntax>DirectoryIndex
60     <var>local-url</var> [<var>local-url</var>] ...</syntax>
61 <default>DirectoryIndex index.html</default>
62 <contextlist><context>server config</context><context>virtual host</context>
63 <context>directory</context><context>.htaccess</context></contextlist>
64 <override>Indexes</override>
65
66 <usage>
67     <p>The <directive>DirectoryIndex</directive> directive sets the
68     list of resources to look for, when the client requests an index
69     of the directory by specifying a / at the end of the directory
70     name.  <var>Local-url</var> is the (%-encoded) URL of a document on
71     the server relative to the requested directory; it is usually the
72     name of a file in the directory. Several URLs may be given, in
73     which case the server will return the first one that it finds.  If
74     none of the resources exist and the <code>Indexes</code> option is
75     set, the server will generate its own listing of the
76     directory.</p>
77
78     <example><title>Example</title>
79       DirectoryIndex index.html
80     </example>
81
82     <p>then a request for <code>http://myserver/docs/</code> would
83     return <code>http://myserver/docs/index.html</code> if it
84     exists, or would list the directory if it did not.</p>
85
86     <p>Note that the documents do not need to be relative to the
87     directory;</p>
88
89     <example>
90       DirectoryIndex index.html index.txt  /cgi-bin/index.pl
91     </example>
92
93     <p>would cause the CGI script <code>/cgi-bin/index.pl</code> to be
94     executed if neither <code>index.html</code> or <code>index.txt</code>
95     existed in a directory.</p>
96 </usage>
97 </directivesynopsis>
98
99 <directivesynopsis>
100 <name>DirectorySlash</name>
101 <description>Toggle trailing slash redirects on or off</description>
102 <syntax>DirectorySlash On|Off</syntax>
103 <default>DirectorySlash On</default>
104 <contextlist><context>server config</context><context>virtual host</context>
105 <context>directory</context><context>.htaccess</context></contextlist>
106 <override>Indexes</override>
107 <compatibility>Available in version 2.0.51 and later</compatibility>
108
109 <usage>
110     <p>The <directive>DirectorySlash</directive> directive determines, whether
111     <module>mod_dir</module> should fixup URLs pointing to a directory or
112     not.</p>
113
114     <p>Typically if a user requests a resource without a trailing slash, which
115     points to a directory, <module>mod_dir</module> redirects him to the same
116     ressource, but <em>with</em> trailing slash for some good reasons:</p>
117
118     <ul>
119     <li>The user is finally requesting the canonical URL of the resource</li>
120     <li><module>mod_autoindex</module> works correctly. Since it doesn't emit
121     the path in the link, it would point to the wrong path.</li>
122     <li><directive module="mod_dir">DirectoryIndex</directive> will be evaluated
123     <em>only</em> for directories requested with trailing slash.</li>
124     <li>Relative URL references inside html pages will work correctly.</li>
125     </ul>
126
127     <p>Well, if you don't want this effect <em>and</em> the reasons above don't
128     apply to you, you can turn off the redirect with:</p>
129
130     <example>
131         # see security warning below!<br />
132         &lt;Location /some/path&gt;<br />
133         <indent>
134             DirectorySlash Off<br />
135             SetHandler some-handler<br />
136         </indent>
137         &lt;/Location&gt;
138     </example>
139
140     <note type="warning"><title>Security Warning</title>
141     <p>Turning off the trailing slash redirect may result in an information
142     disclosure. Consider a situation where <module>mod_autoindex</module> is
143     active (<code>Options +Indexes</code>) and <directive module="mod_dir"
144     >DirectoryIndex</directive> is set to a valid resource (say,
145     <code>index.html</code>) and there's no other special handler defined for
146     that URL. In this case a request with a trailing slash would show the
147     <code>index.html</code> file. <strong>But a request without trailing slash
148     would list the directory contents</strong>.</p>
149     </note>
150 </usage>
151 </directivesynopsis>
152
153 </modulesynopsis>