mod_dir.html.en revision 90361ddfb3a8abaa0f8fb1729732062c78d8dc50
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This file is generated from xml source: DO NOT EDIT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-->
<title>mod_dir - Apache HTTP Server</title>
<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<body>
<div id="page-header">
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
<p class="apache">Apache HTTP Server Version 2.1</p>
<div id="path">
<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Modules</a></div>
<div id="page-content">
<div id="preamble"><h1>Apache Module mod_dir</h1>
<div class="toplang">
<p><span>Available Languages: </span><a href="/en/mod/mod_dir.html" title="English"> en </a> |
</div>
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for "trailing slash" redirects and
serving directory index files</td></tr>
<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>dir_module</td></tr>
<h3>Summary</h3>
<p>The index of a directory can come from one of two sources:</p>
<ul>
<li>A file written by the user, typically called
<code>index.html</code>. The <code class="directive"><a href="#directoryindex">DirectoryIndex</a></code> directive sets the
name of this file. This is controlled by
<li>Otherwise, a listing generated by the server. This is
</ul>
<p>The two functions are separated so that you can completely
remove (or replace) automatic index generation should you want
to.</p>
<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 <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> issues a redirect to
</div>
<div id="quickview"><h3 class="directives">Directives</h3>
<ul id="toc">
</ul>
</div>
<div class="directive-section"><h2><a name="DirectoryIndex" id="DirectoryIndex">DirectoryIndex</a> <a name="directoryindex" id="directoryindex">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>List of resources to look for when the client requests
a directory</td></tr>
<var>local-url</var> [<var>local-url</var>] ...</code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>DirectoryIndex index.html</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
</table>
<p>The <code class="directive">DirectoryIndex</code> 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>
<div class="example"><h3>Example</h3><p><code>
DirectoryIndex index.html
</code></p></div>
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>
<div class="example"><p><code>
</code></p></div>
existed in a directory.</p>
</div>
<div class="directive-section"><h2><a name="DirectorySlash" id="DirectorySlash">DirectorySlash</a> <a name="directoryslash" id="directoryslash">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Toggle trailing slash redirects on or off</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>DirectorySlash On|Off</code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>DirectorySlash On</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.51 and later</td></tr>
</table>
<p>The <code class="directive">DirectorySlash</code> directive determines, whether
<code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> 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, <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> 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><code class="module"><a href="/mod/mod_autoindex.html">mod_autoindex</a></code> works correctly. Since it doesn't emit
the path in the link, it would point to the wrong path.</li>
<li><code class="directive"><a href="#directoryindex">DirectoryIndex</a></code> 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>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>
<div class="example"><p><code>
# see security warning below!<br />
<span class="indent">
DirectorySlash Off<br />
SetHandler some-handler<br />
</span>
</Location>
</code></p></div>
<div class="warning"><h3>Security Warning</h3>
<p>Turning off the trailing slash redirect may result in an information
disclosure. Consider a situation where <code class="module"><a href="/mod/mod_autoindex.html">mod_autoindex</a></code> is
active (<code>Options +Indexes</code>) and <code class="directive"><a href="#directoryindex">DirectoryIndex</a></code> is set to a valid resource (say,
that URL. In this case a request with a trailing slash would show the
would list the directory contents</strong>.</p>
</div>
</div>
</div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="/en/mod/mod_dir.html" title="English"> en </a> |
</div><div id="footer">
<p class="apache">Copyright 1995-2005 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
</body></html>