<
li>Otherwise, a listing generated by the server. This is
provided by <
module>mod_autoindex</
module>.</
li>
<
p>The two functions are separated so that you can completely
remove (or replace) automatic index generation should you want
<
p>A "trailing slash" redirect is issued when the server
receives a request for a URL
<
code>dirname</
code> is a directory. Directories require a
trailing slash, so <
module>mod_dir</
module> issues a redirect to
<
name>DirectoryIndex</
name>
<
description>List of resources to look for when the client requests
a directory</
description>
disabled | <
var>local-url</
var> [<
var>local-url</
var>] ...</
syntax>
<
contextlist><
context>server config</
context><
context>virtual host</
context>
<
context>directory</
context><
context>.htaccess</
context></
contextlist>
<
override>Indexes</
override>
<
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
<
example><
title>Example</
title>
exists, or would list the directory if it did not.</
p>
<
p>Note that the documents do not need to be relative to the
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 interpeted
literally if it has any arguments before or after it, even if they are "disabled"
<
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>
<
compatibility>Available in version 2.0.51 and later</
compatibility>
<
p>The <
directive>DirectorySlash</
directive> directive determines whether
<
module>mod_dir</
module> should fixup URLs pointing to a directory or
<
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>
<
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>
<
p>Well, if you don't want this effect <
em>and</
em> the reasons above don't
apply to you, you can turn off the redirect with:</
p>
# see security warning below!<
br />
SetHandler some-handler<
br />
<
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>
<
name>FallbackResource</
name>
<
description>Define a default URL for requests that don't map to a file</
description>
<
syntax>FallbackResource <
var>local-url</
var></
syntax>
<
default>None - 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>
<
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).
<
p>will cause requests for non-existent files to be handled by
<
code>
not-404.php</
code>, while requests for files that exist
<
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>
<
p>Existing files, such as images, css files, and so on, will be
<
em>sub-URI</
em> has to be supplied as <
var>local-url</
var>:</
p>