mod_dir.xml revision c71d76178cda93ed4f5ae4098b03f1533aede614
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen<?xml version="1.0"?>
24fed8aca238e6878aa9c85c82e83a0a7ee3ced3Timo Sirainen<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen<!-- $LastChangedRevision$ -->
d3b29d4b61f1549244a7509b798be6f806cf7d4eTimo Sirainen
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen<!--
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen Licensed to the Apache Software Foundation (ASF) under one or more
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen contributor license agreements. See the NOTICE file distributed with
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen this work for additional information regarding copyright ownership.
78919bf7cb55e84e5f289f33526579f63c4797d7Timo Sirainen The ASF licenses this file to You under the Apache License, Version 2.0
3a916a3c77a476a799425b958a0ac83b93808088Timo Sirainen (the "License"); you may not use this file except in compliance with
379175cfba8150d481d9898b78330b719d128d84Timo Sirainen the License. You may obtain a copy of the License at
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen
c33d3f93abf8392fdc60e12bea41ffd12cc85a8dTimo Sirainen http://www.apache.org/licenses/LICENSE-2.0
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen Unless required by applicable law or agreed to in writing, software
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen distributed under the License is distributed on an "AS IS" BASIS,
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen See the License for the specific language governing permissions and
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen limitations under the License.
8b7e479f8d3d43eb8b98932a562dd5330b0d02bdTimo Sirainen-->
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
5035404202587543bb4843d4aec46331651b6e16Timo Sirainen<modulesynopsis metafile="mod_dir.xml.meta">
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch<name>mod_dir</name>
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen<description>Provides for "trailing slash" redirects and
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen serving directory index files</description>
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen<status>Base</status>
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen<sourcefile>mod_dir.c</sourcefile>
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen<identifier>dir_module</identifier>
8e0e5842b5841cf3065ed18e8ba093b11517c51dTimo Sirainen
b691d7bad5acc2043cd7f598352f4c9a7f8aebb6Timo Sirainen<summary>
6649a54aca033fcbbbb73e5999b95b828bd6b54cTimo Sirainen <p>The index of a directory can come from one of two sources:</p>
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen
a34bb3d3ad889eb05e3f1c0a446692e1f3527e14Timo Sirainen <ul>
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen <li>A file written by the user, typically called
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen <code>index.html</code>. The <directive module="mod_dir"
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen >DirectoryIndex</directive> directive sets the
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen name of this file. This is controlled by
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen <module>mod_dir</module>.</li>
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen <li>Otherwise, a listing generated by the server. This is
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen provided by <module>mod_autoindex</module>.</li>
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch </ul>
52cb31b413be19de11cdf9ad84b9ccde7740b5cfTimo Sirainen <p>The two functions are separated so that you can completely
52cb31b413be19de11cdf9ad84b9ccde7740b5cfTimo Sirainen remove (or replace) automatic index generation should you want
58c61ac5650583d21c891e61e051c614290d31fbTimo Sirainen to.</p>
315ce5be539bfe8bc7777ab0654499c49583cea2Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen <p>A "trailing slash" redirect is issued when the server
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen receives a request for a URL
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen <code>http://servername/foo/dirname</code> where
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen <code>dirname</code> is a directory. Directories require a
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen trailing slash, so <module>mod_dir</module> issues a redirect to
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen <code>http://servername/foo/dirname/</code>.</p>
110a08d8903a6037940a2ad93dac64aca71c17e1Timo Sirainen</summary>
ede6bdb42c76bf84add9071b9fe14586646aeaf7Timo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen<directivesynopsis>
<name>DirectoryIndex</name>
<description>List of resources to look for when the client requests
a directory</description>
<syntax>DirectoryIndex
disabled | <var>local-url</var> [<var>local-url</var>] ...</syntax>
<default>DirectoryIndex index.html</default>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>Indexes</override>
<usage>
<p>The <directive>DirectoryIndex</directive> 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 directory
name. <var>Local-url</var> 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><title>Example</title>
<highlight language="config">
DirectoryIndex index.html
</highlight>
</example>
<p>then a request for <code>http://example.com/docs/</code> would
return <code>http://example.com/docs/index.html</code> if it
exists, or would list the directory if it did not.</p>
<p>Note that the documents do not need to be relative to the
directory;</p>
<highlight language="config">
DirectoryIndex index.html index.txt /cgi-bin/index.pl
</highlight>
<p>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>
<p>A single argument of "disabled" prevents <module>mod_dir</module> from
searching for an index. An argument of "disabled" will be interpreted
literally if it has any arguments before or after it, even if they are "disabled"
as well.</p>
<p><strong>Note:</strong> Multiple <directive>DirectoryIndex</directive>
directives within the <a href="/sections.html"><em>same context</em></a> will add
to the list of resources to look for rather than replace:
</p>
<highlight language="config">
# Example A: Set index.html as an index page, then add index.php to that list as well.
&lt;Directory /foo&gt;
DirectoryIndex index.html
DirectoryIndex index.php
&lt;/Directory&gt;
# Example B: This is identical to example A, except it's done with a single directive.
&lt;Directory /foo&gt;
DirectoryIndex index.html index.php
&lt;/Directory&gt;
# Example C: To replace the list, you must explicitly reset it first:
# In this example, only index.php will remain as an index resource.
&lt;Directory /foo&gt;
DirectoryIndex index.html
DirectoryIndex disabled
DirectoryIndex index.php
&lt;/Directory&gt;
</highlight>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>DirectoryIndexRedirect</name>
<description>Configures an external redirect for directory indexes.
</description>
<syntax>DirectoryIndexRedirect on | off | permanent | temp | seeother |
<var>3xx-code</var>
</syntax>
<default>DirectoryIndexRedirect off</default>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>Indexes</override>
<compatibility>Available in version 2.3.14 and later</compatibility>
<usage>
<p>By default, the <directive>DirectoryIndex</directive> is selected
and returned transparently to the client. <directive
>DirectoryIndexRedirect</directive> causes an external redirect
to instead be issued.</p>
<p> The argument can be : </p>
<ul>
<li><code>on</code> : issues a 302 redirection to the index resource.</li>
<li><code>off</code> : does not issue a redirection. This is the legacy behaviour of mod_dir.</li>
<li><code>permanent</code> : issues a 301 (permanent) redirection to the index resource.</li>
<li><code>temp</code> : this has the same effect as <code>on</code></li>
<li><code>seeother</code> : issues a 303 redirection (also known as "See Other") to the index resource.</li>
<li><var>3xx-code</var> : issues a redirection marked by the chosen 3xx code.</li>
</ul>
<example><title>Example</title>
<highlight language="config">
DirectoryIndexRedirect on
</highlight>
</example>
<p>A request for <code>http://example.com/docs/</code> would
return a temporary redirect to <code
>http://example.com/docs/index.html</code>
if it exists.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>DirectorySlash</name>
<description>Toggle trailing slash redirects on or off</description>
<syntax>DirectorySlash On|Off</syntax>
<default>DirectorySlash On</default>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>Indexes</override>
<usage>
<p>The <directive>DirectorySlash</directive> directive determines whether
<module>mod_dir</module> should fixup URLs pointing to a directory or
not.</p>
<p>Typically if a user requests a resource without a trailing slash, which
points to a directory, <module>mod_dir</module> redirects him to the same
resource, but <em>with</em> trailing slash for some good reasons:</p>
<ul>
<li>The user is finally requesting the canonical URL of the resource</li>
<li><module>mod_autoindex</module> works correctly. Since it doesn't emit
the path in the link, it would point to the wrong path.</li>
<li><directive module="mod_dir">DirectoryIndex</directive> will be evaluated
<em>only</em> for directories requested with trailing slash.</li>
<li>Relative URL references inside html pages will work correctly.</li>
</ul>
<p>If you don't want this effect <em>and</em> the reasons above don't
apply to you, you can turn off the redirect as shown below. However,
be aware that there are possible security implications to doing
this.</p>
<highlight language="config">
# see security warning below!
&lt;Location /some/path&gt;
DirectorySlash Off
SetHandler some-handler
&lt;/Location&gt;
</highlight>
<note type="warning"><title>Security Warning</title>
<p>Turning off the trailing slash redirect may result in an information
disclosure. Consider a situation where <module>mod_autoindex</module> is
active (<code>Options +Indexes</code>) and <directive module="mod_dir"
>DirectoryIndex</directive> is set to a valid resource (say,
<code>index.html</code>) and there's no other special handler defined for
that URL. In this case a request with a trailing slash would show the
<code>index.html</code> file. <strong>But a request without trailing slash
would list the directory contents</strong>.</p>
</note>
<p>Also note that some browsers may erroneously change POST requests into GET
(thus discarding POST data) when a redirect is issued.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>FallbackResource</name>
<description>Define a default URL for requests that don't map to a file</description>
<syntax>FallbackResource disabled | <var>local-url</var></syntax>
<default>disabled - httpd will return 404 (Not Found)</default>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>Indexes</override>
<usage>
<p>Use this to set a handler for any URL that doesn't map to anything
in your filesystem, and would otherwise return HTTP 404 (Not Found).
For example</p>
<highlight language="config">
FallbackResource /not-404.php
</highlight>
<p>will cause requests for non-existent files to be handled by
<code>not-404.php</code>, while requests for files that exist
are unaffected.</p>
<p>It is frequently desirable to have a single file or resource
handle all requests to a particular directory, except those requests
that correspond to an existing file or script. This is often
referred to as a 'front controller.'</p>
<p>In earlier versions of httpd, this effect typically required
<module>mod_rewrite</module>, and the use of the <code>-f</code> and
<code>-d</code> tests for file and directory existence. This now
requires only one line of configuration.</p>
<highlight language="config">
FallbackResource /index.php
</highlight>
<p>Existing files, such as images, css files, and so on, will be
served normally.</p>
<p>Use the <code>disabled</code> argument to disable that feature
if inheritance from a parent directory is not desired.</p>
<p>In a sub-URI, such as <em>http://example.com/blog/</em> this
<em>sub-URI</em> has to be supplied as <var>local-url</var>:</p>
<highlight language="config">
&lt;Directory /web/example.com/htdocs/blog&gt;
FallbackResource /blog/index.php
&lt;/Directory&gt;
&lt;Directory /web/example.com/htdocs/blog/images&gt;
FallbackResource disabled
&lt;/Directory&gt;
</highlight>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>DirectoryCheckHandler</name>
<description>Toggle how this module responds when another handler is configured</description>
<syntax>DirectoryCheckHandler On|Off</syntax>
<default>DirectoryCheckHandler Off</default>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>Indexes</override>
<compatibility>Available in 2.4.8 and later. Releases prior to 2.4 implicitly
act as if "DirectoryCheckHandler ON" was specified.</compatibility>
<usage>
<p>The <directive>DirectoryCheckHandler</directive> directive determines
whether <module>mod_dir</module> should check for directory indexes or
add trailing slashes when some other handler has been configured for
the current URL. Handlers can be set by directives such as
<directive module="core">SetHandler</directive> or by other modules at
runtime. </p>
<p> In releases prior to 2.4, this module did not take any action if any
other handler was configured for a URL. This allows directory indexes to
be served even when a <directive>SetHandler</directive> directive is
specified for an entire directory, but it can also result in some conflicts
with other modules.</p>
</usage>
</directivesynopsis>
</modulesynopsis>