mod_dir.html.en revision 0332c9af2f43b2bf29133b19d06306a735b2d4a6
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml version="1.0" encoding="ISO-8859-1"?>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive This file is generated from xml source: DO NOT EDIT
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
b686b6a420bde7f78c416b90be11db94cb789979nd -->
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc<title>mod_dir - Apache HTTP Server</title>
b686b6a420bde7f78c416b90be11db94cb789979nd<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
b686b6a420bde7f78c416b90be11db94cb789979nd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
2e545ce2450a9953665f701bb05350f0d3f26275nd<script src="/style/scripts/prettify.js" type="text/javascript">
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen</script>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
b686b6a420bde7f78c416b90be11db94cb789979nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
b686b6a420bde7f78c416b90be11db94cb789979nd<body>
b686b6a420bde7f78c416b90be11db94cb789979nd<div id="page-header">
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<p class="apache">Apache HTTP Server Version 2.5</p>
b686b6a420bde7f78c416b90be11db94cb789979nd<img alt="" src="/images/feather.gif" /></div>
b686b6a420bde7f78c416b90be11db94cb789979nd<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
b686b6a420bde7f78c416b90be11db94cb789979nd<div id="path">
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
b686b6a420bde7f78c416b90be11db94cb789979nd<div id="page-content">
b686b6a420bde7f78c416b90be11db94cb789979nd<div id="preamble"><h1>Apache Module mod_dir</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="toplang">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/mod/mod_dir.html" title="English">&nbsp;en&nbsp;</a> |
d28579afd45cc42da1422161721fb12f9cf366b9nd<a href="/fr/mod/mod_dir.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd<a href="/ja/mod/mod_dir.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
1ac39787115a288f5e848344b1b1e8dccb1c58f1nd<a href="/ko/mod/mod_dir.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/tr/mod/mod_dir.html" hreflang="tr" rel="alternate" title="T�rk�e">&nbsp;tr&nbsp;</a></p>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd</div>
b686b6a420bde7f78c416b90be11db94cb789979nd<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for "trailing slash" redirects and
b686b6a420bde7f78c416b90be11db94cb789979nd serving directory index files</td></tr>
b686b6a420bde7f78c416b90be11db94cb789979nd<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
b686b6a420bde7f78c416b90be11db94cb789979nd<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>dir_module</td></tr>
b686b6a420bde7f78c416b90be11db94cb789979nd<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_dir.c</td></tr></table>
b686b6a420bde7f78c416b90be11db94cb789979nd<h3>Summary</h3>
b686b6a420bde7f78c416b90be11db94cb789979nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The index of a directory can come from one of two sources:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>A file written by the user, typically called
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>index.html</code>. The <code class="directive"><a href="#directoryindex">DirectoryIndex</a></code> directive sets the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive name of this file. This is controlled by
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>Otherwise, a listing generated by the server. This is
97a9a944b5887e91042b019776c41d5dd74557aferikabele provided by <code class="module"><a href="/mod/mod_autoindex.html">mod_autoindex</a></code>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The two functions are separated so that you can completely
06ba4a61654b3763ad65f52283832ebf058fdf1cslive remove (or replace) automatic index generation should you want
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf to.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>A "trailing slash" redirect is issued when the server
06ba4a61654b3763ad65f52283832ebf058fdf1cslive receives a request for a URL
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>http://servername/foo/dirname</code> where
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>dirname</code> is a directory. Directories require a
97a9a944b5887e91042b019776c41d5dd74557aferikabele trailing slash, so <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> issues a redirect to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>http://servername/foo/dirname/</code>.</p>
b686b6a420bde7f78c416b90be11db94cb789979nd</div>
b686b6a420bde7f78c416b90be11db94cb789979nd<div id="quickview"><h3 class="directives">Directives</h3>
b686b6a420bde7f78c416b90be11db94cb789979nd<ul id="toc">
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<li><img alt="" src="/images/down.gif" /> <a href="#directoryindex">DirectoryIndex</a></li>
b686b6a420bde7f78c416b90be11db94cb789979nd<li><img alt="" src="/images/down.gif" /> <a href="#directoryindexredirect">DirectoryIndexRedirect</a></li>
c31366647a84875104bb9cbca53280b607c37595covener<li><img alt="" src="/images/down.gif" /> <a href="#directoryslash">DirectorySlash</a></li>
4cc6016bd30b0852222630a0ed62805e36f345d1nd<li><img alt="" src="/images/down.gif" /> <a href="#fallbackresource">FallbackResource</a></li>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen</ul>
b686b6a420bde7f78c416b90be11db94cb789979nd<ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<div class="directive-section"><h2><a name="DirectoryIndex" id="DirectoryIndex">DirectoryIndex</a> <a name="directoryindex" id="directoryindex">Directive</a></h2>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<table class="directive">
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>List of resources to look for when the client requests
f4cbda69df0490c6deaacb8d04f103d200ddd183nda directory</td></tr>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>DirectoryIndex
df4578cbf77fc9e35ccade1f01b137b7eea5ede6nd disabled | <var>local-url</var> [<var>local-url</var>] ...</code></td></tr>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>DirectoryIndex index.html</code></td></tr>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Indexes</td></tr>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_dir</td></tr>
df4578cbf77fc9e35ccade1f01b137b7eea5ede6nd</table>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd <p>The <code class="directive">DirectoryIndex</code> directive sets the
f4cbda69df0490c6deaacb8d04f103d200ddd183nd list of resources to look for, when the client requests an index
f4cbda69df0490c6deaacb8d04f103d200ddd183nd of the directory by specifying a / at the end of the directory
f4cbda69df0490c6deaacb8d04f103d200ddd183nd name. <var>Local-url</var> is the (%-encoded) URL of a document on
f4cbda69df0490c6deaacb8d04f103d200ddd183nd the server relative to the requested directory; it is usually the
f4cbda69df0490c6deaacb8d04f103d200ddd183nd name of a file in the directory. Several URLs may be given, in
f4cbda69df0490c6deaacb8d04f103d200ddd183nd which case the server will return the first one that it finds. If
f4cbda69df0490c6deaacb8d04f103d200ddd183nd none of the resources exist and the <code>Indexes</code> option is
f4cbda69df0490c6deaacb8d04f103d200ddd183nd set, the server will generate its own listing of the
f4cbda69df0490c6deaacb8d04f103d200ddd183nd directory.</p>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd
f4cbda69df0490c6deaacb8d04f103d200ddd183nd <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">
f4cbda69df0490c6deaacb8d04f103d200ddd183nd DirectoryIndex index.html
f4cbda69df0490c6deaacb8d04f103d200ddd183nd </pre>
f4cbda69df0490c6deaacb8d04f103d200ddd183nd</div>
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd <p>then a request for <code>http://example.com/docs/</code> would
b686b6a420bde7f78c416b90be11db94cb789979nd return <code>http://example.com/docs/index.html</code> if it
b686b6a420bde7f78c416b90be11db94cb789979nd exists, or would list the directory if it did not.</p>
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd <p>Note that the documents do not need to be relative to the
b6d2c204c150843e48f6787c1090ae75b718896ecovener directory;</p>
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd <pre class="prettyprint lang-config">
b686b6a420bde7f78c416b90be11db94cb789979nd DirectoryIndex index.html index.txt /cgi-bin/index.pl
b686b6a420bde7f78c416b90be11db94cb789979nd </pre>
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>would cause the CGI script <code>/cgi-bin/index.pl</code> to be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive executed if neither <code>index.html</code> or <code>index.txt</code>
1887c0b8ceab2c8d64a1e5b3aa512e77b86b49fayoshiki existed in a directory.</p>
f5cbf3a7818c08d2f19c04fdf4f47257eea7d3c6nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>A single argument of "disabled" prevents <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> from
06ba4a61654b3763ad65f52283832ebf058fdf1cslive searching for an index. An argument of "disabled" will be interpreted
06ba4a61654b3763ad65f52283832ebf058fdf1cslive literally if it has any arguments before or after it, even if they are "disabled"
06ba4a61654b3763ad65f52283832ebf058fdf1cslive as well.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Note:</strong> Multiple <code class="directive">DirectoryIndex</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive directives within the <a href="/sections.html"><em>same context</em></a> will add
20f499565e77defe9dab24dd85c02f38a1175855nd to the list of resources to look for rather than replace:
e487d6c09669296f94a5190cc34586a98e624a00nd </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <pre class="prettyprint lang-config">
c31366647a84875104bb9cbca53280b607c37595covener# Example A: Set index.html as an index page, then add index.php to that list as well.
c31366647a84875104bb9cbca53280b607c37595covener&lt;Directory /foo&gt;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive DirectoryIndex index.html
06ba4a61654b3763ad65f52283832ebf058fdf1cslive DirectoryIndex index.php
06ba4a61654b3763ad65f52283832ebf058fdf1cslive&lt;/Directory&gt;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# Example B: This is identical to example A, except it's done with a single directive.
20f499565e77defe9dab24dd85c02f38a1175855nd&lt;Directory /foo&gt;
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh DirectoryIndex index.html index.php
f5cbf3a7818c08d2f19c04fdf4f47257eea7d3c6nd&lt;/Directory&gt;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
f5cbf3a7818c08d2f19c04fdf4f47257eea7d3c6nd# Example C: To replace the list, you must explicitly do so:
f5cbf3a7818c08d2f19c04fdf4f47257eea7d3c6nd# In this example, only index.php will remain as an index resource.
b686b6a420bde7f78c416b90be11db94cb789979nd&lt;Directory /foo&gt;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf DirectoryIndex index.html
e2d704f65ae715639ae9d21d98bbf19ebcad58ffhumbedooh DirectoryIndex disabled
b6d2c204c150843e48f6787c1090ae75b718896ecovener DirectoryIndex index.php
b6d2c204c150843e48f6787c1090ae75b718896ecovener&lt;/Directory&gt;
63de18ba5e922ffaab500317d7d1d0ad6b27b7e2covener </pre>
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh
daf4d4394c14b23e06073c13806259a2dc7574b4humbedooh</div>
4aa603e6448b99f9371397d439795c91a93637eand<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar<div class="directive-section"><h2><a name="DirectoryIndexRedirect" id="DirectoryIndexRedirect">DirectoryIndexRedirect</a> <a name="directoryindexredirect" id="directoryindexredirect">Directive</a></h2>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<table class="directive">
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Configures an external redirect for directory indexes.
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh</td></tr>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>DirectoryIndexRedirect on | off | permanent | temp | seeother |
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<var>3xx-code</var>
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar</code></td></tr>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>DirectoryIndexRedirect off</code></td></tr>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Indexes</td></tr>
8db1460fc707c9d9e2a8286808244254d4a0c949humbedooh<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_dir</td></tr>
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.3.14 and later</td></tr>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh</table>
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh <p>By default, the <code class="directive">DirectoryIndex</code> is selected
0332c9af2f43b2bf29133b19d06306a735b2d4a6humbedooh and returned transparently to the client. <code class="directive">DirectoryIndexRedirect</code> causes an external redirect
4aa603e6448b99f9371397d439795c91a93637eand to instead be issued.</p>
daf4d4394c14b23e06073c13806259a2dc7574b4humbedooh
daf4d4394c14b23e06073c13806259a2dc7574b4humbedooh <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">
63de18ba5e922ffaab500317d7d1d0ad6b27b7e2covener DirectoryIndexRedirect on
c31366647a84875104bb9cbca53280b607c37595covener </pre>
c31366647a84875104bb9cbca53280b607c37595covener</div>
c31366647a84875104bb9cbca53280b607c37595covener
c31366647a84875104bb9cbca53280b607c37595covener <p>A request for <code>http://example.com/docs/</code> would
c31366647a84875104bb9cbca53280b607c37595covener return a temporary redirect to <code>http://example.com/docs/index.html</code>
c31366647a84875104bb9cbca53280b607c37595covener if it exists.</p>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
c31366647a84875104bb9cbca53280b607c37595covener
c31366647a84875104bb9cbca53280b607c37595covener</div>
c31366647a84875104bb9cbca53280b607c37595covener<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
c31366647a84875104bb9cbca53280b607c37595covener<div class="directive-section"><h2><a name="DirectorySlash" id="DirectorySlash">DirectorySlash</a> <a name="directoryslash" id="directoryslash">Directive</a></h2>
c31366647a84875104bb9cbca53280b607c37595covener<table class="directive">
c31366647a84875104bb9cbca53280b607c37595covener<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Toggle trailing slash redirects on or off</td></tr>
c31366647a84875104bb9cbca53280b607c37595covener<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>DirectorySlash On|Off</code></td></tr>
1462ff536f1b939bb337766b2056109c29664c4erbowen<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>DirectorySlash On</code></td></tr>
c31366647a84875104bb9cbca53280b607c37595covener<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
c31366647a84875104bb9cbca53280b607c37595covener<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Indexes</td></tr>
c31366647a84875104bb9cbca53280b607c37595covener<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
c31366647a84875104bb9cbca53280b607c37595covener<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_dir</td></tr>
c31366647a84875104bb9cbca53280b607c37595covener<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.51 and later</td></tr>
0237f43ab925775250e266e479d0a337ff374a4btakashi</table>
650401e2cb916188d0e1a280dfa78dd67e24ce3bgryzor <p>The <code class="directive">DirectorySlash</code> directive determines whether
0237f43ab925775250e266e479d0a337ff374a4btakashi <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> should fixup URLs pointing to a directory or
0237f43ab925775250e266e479d0a337ff374a4btakashi not.</p>
0237f43ab925775250e266e479d0a337ff374a4btakashi
0237f43ab925775250e266e479d0a337ff374a4btakashi <p>Typically if a user requests a resource without a trailing slash, which
0237f43ab925775250e266e479d0a337ff374a4btakashi points to a directory, <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> redirects him to the same
0237f43ab925775250e266e479d0a337ff374a4btakashi resource, but <em>with</em> trailing slash for some good reasons:</p>
650401e2cb916188d0e1a280dfa78dd67e24ce3bgryzor
650401e2cb916188d0e1a280dfa78dd67e24ce3bgryzor <ul>
650401e2cb916188d0e1a280dfa78dd67e24ce3bgryzor <li>The user is finally requesting the canonical URL of the resource</li>
20f499565e77defe9dab24dd85c02f38a1175855nd <li><code class="module"><a href="/mod/mod_autoindex.html">mod_autoindex</a></code> works correctly. Since it doesn't emit
e487d6c09669296f94a5190cc34586a98e624a00nd the path in the link, it would point to the wrong path.</li>
c31366647a84875104bb9cbca53280b607c37595covener <li><code class="directive"><a href="#directoryindex">DirectoryIndex</a></code> will be evaluated
c31366647a84875104bb9cbca53280b607c37595covener <em>only</em> for directories requested with trailing slash.</li>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <li>Relative URL references inside html pages will work correctly.</li>
c31366647a84875104bb9cbca53280b607c37595covener </ul>
c31366647a84875104bb9cbca53280b607c37595covener
c31366647a84875104bb9cbca53280b607c37595covener <p>If you don't want this effect <em>and</em> the reasons above don't
4cc6016bd30b0852222630a0ed62805e36f345d1nd apply to you, you can turn off the redirect as shown below. However,
4cc6016bd30b0852222630a0ed62805e36f345d1nd be aware that there are possible security implications to doing
4cc6016bd30b0852222630a0ed62805e36f345d1nd this.</p>
4cc6016bd30b0852222630a0ed62805e36f345d1nd
4cc6016bd30b0852222630a0ed62805e36f345d1nd <pre class="prettyprint lang-config">
4cc6016bd30b0852222630a0ed62805e36f345d1nd# see security warning below!
4cc6016bd30b0852222630a0ed62805e36f345d1nd&lt;Location /some/path&gt;
4cc6016bd30b0852222630a0ed62805e36f345d1nd DirectorySlash Off
4cc6016bd30b0852222630a0ed62805e36f345d1nd SetHandler some-handler
4cc6016bd30b0852222630a0ed62805e36f345d1nd&lt;/Location&gt;
4cc6016bd30b0852222630a0ed62805e36f345d1nd </pre>
4cc6016bd30b0852222630a0ed62805e36f345d1nd
b622a4d68a26af5386003d4c69a950bc1e157005rbowen
4cc6016bd30b0852222630a0ed62805e36f345d1nd <div class="warning"><h3>Security Warning</h3>
4cc6016bd30b0852222630a0ed62805e36f345d1nd <p>Turning off the trailing slash redirect may result in an information
4cc6016bd30b0852222630a0ed62805e36f345d1nd disclosure. Consider a situation where <code class="module"><a href="/mod/mod_autoindex.html">mod_autoindex</a></code> is
4cc6016bd30b0852222630a0ed62805e36f345d1nd active (<code>Options +Indexes</code>) and <code class="directive"><a href="#directoryindex">DirectoryIndex</a></code> is set to a valid resource (say,
4cc6016bd30b0852222630a0ed62805e36f345d1nd <code>index.html</code>) and there's no other special handler defined for
90361ddfb3a8abaa0f8fb1729732062c78d8dc50niq that URL. In this case a request with a trailing slash would show the
4cc6016bd30b0852222630a0ed62805e36f345d1nd <code>index.html</code> file. <strong>But a request without trailing slash
4cc6016bd30b0852222630a0ed62805e36f345d1nd would list the directory contents</strong>.</p>
4cc6016bd30b0852222630a0ed62805e36f345d1nd </div>
4cc6016bd30b0852222630a0ed62805e36f345d1nd <p>Also note that some browsers may erroneously change POST requests into GET
4cc6016bd30b0852222630a0ed62805e36f345d1nd (thus discarding POST data) when a redirect is issued.</p>
4cc6016bd30b0852222630a0ed62805e36f345d1nd
4cc6016bd30b0852222630a0ed62805e36f345d1nd</div>
95d05f094d56c5986659f1aa7e57f258850b1287nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
4cc6016bd30b0852222630a0ed62805e36f345d1nd<div class="directive-section"><h2><a name="FallbackResource" id="FallbackResource">FallbackResource</a> <a name="fallbackresource" id="fallbackresource">Directive</a></h2>
4cc6016bd30b0852222630a0ed62805e36f345d1nd<table class="directive">
b622a4d68a26af5386003d4c69a950bc1e157005rbowen<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Define a default URL for requests that don't map to a file</td></tr>
b622a4d68a26af5386003d4c69a950bc1e157005rbowen<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>FallbackResource <var>local-url</var></code></td></tr>
b622a4d68a26af5386003d4c69a950bc1e157005rbowen<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>None - httpd will return 404 (Not Found)</code></td></tr>
b622a4d68a26af5386003d4c69a950bc1e157005rbowen<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
4cc6016bd30b0852222630a0ed62805e36f345d1nd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Indexes</td></tr>
4aa603e6448b99f9371397d439795c91a93637eand<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_dir</td></tr>
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh</table>
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh <p>Use this to set a handler for any URL that doesn't map to anything
4aa603e6448b99f9371397d439795c91a93637eand in your filesystem, and would otherwise return HTTP 404 (Not Found).
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh For example</p>
4cc6016bd30b0852222630a0ed62805e36f345d1nd <pre class="prettyprint lang-config">
4cc6016bd30b0852222630a0ed62805e36f345d1nd FallbackResource /not-404.php
4cc6016bd30b0852222630a0ed62805e36f345d1nd </pre>
4cc6016bd30b0852222630a0ed62805e36f345d1nd
4cc6016bd30b0852222630a0ed62805e36f345d1nd <p>will cause requests for non-existent files to be handled by
4cc6016bd30b0852222630a0ed62805e36f345d1nd <code>not-404.php</code>, while requests for files that exist
4cc6016bd30b0852222630a0ed62805e36f345d1nd are unaffected.</p>
4cc6016bd30b0852222630a0ed62805e36f345d1nd <p>It is frequently desirable to have a single file or resource
4cc6016bd30b0852222630a0ed62805e36f345d1nd handle all requests to a particular directory, except those requests
4cc6016bd30b0852222630a0ed62805e36f345d1nd that correspond to an existing file or script. This is often
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor referred to as a 'front controller.'</p>
a01665d9a2baf14d3928df50e5c36c8e84d71b41humbedooh <p>In earlier versions of httpd, this effect typically required
4cc6016bd30b0852222630a0ed62805e36f345d1nd <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>, and the use of the <code>-f</code> and
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen <code>-d</code> tests for file and directory existence. This now
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen requires only one line of configuration.</p>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen <pre class="prettyprint lang-config">
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen FallbackResource /index.php
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen </pre>
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor <p>Existing files, such as images, css files, and so on, will be
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen served normally.</p>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen <p>In a sub-URI, such as <em>http://example.com/blog/</em> this
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen <em>sub-URI</em> has to be supplied as <var>local-url</var>:</p>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen <pre class="prettyprint lang-config">
0237f43ab925775250e266e479d0a337ff374a4btakashi&lt;Directory /web/example.com/htdocs/blog&gt;
0237f43ab925775250e266e479d0a337ff374a4btakashi FallbackResource /blog/index.php
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen&lt;/Directory&gt;
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen </pre>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen
20f499565e77defe9dab24dd85c02f38a1175855nd</div>
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh</div>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen<div class="bottomlang">
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen<p><span>Available Languages: </span><a href="/en/mod/mod_dir.html" title="English">&nbsp;en&nbsp;</a> |
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen<a href="/fr/mod/mod_dir.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen<a href="/ja/mod/mod_dir.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen<a href="/ko/mod/mod_dir.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen<a href="/tr/mod/mod_dir.html" hreflang="tr" rel="alternate" title="T�rk�e">&nbsp;tr&nbsp;</a></p>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen<script type="text/javascript"><!--//--><![CDATA[//><!--
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowenvar comments_shortname = 'httpd';
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowenvar comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_dir.html';
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen(function(w, d) {
20f499565e77defe9dab24dd85c02f38a1175855nd if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh d.write('<div id="comments_thread"><\/div>');
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen var s = d.createElement('script');
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowen s.type = 'text/javascript';
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor s.async = true;
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor s.src = 'https://c.apaste.info/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
4f32f36773e84a2ec9a930f85b44d31fc0c0c2cfigalic (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
4f32f36773e84a2ec9a930f85b44d31fc0c0c2cfigalic }
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar else {
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor }
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar})(window, document);
02c8e4c50471e515a88620bddba4d15ad2384f8bgryzor//--><!]]></script></div><div id="footer">
4aa603e6448b99f9371397d439795c91a93637eand<p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
23255b04d466bf2621c4dd4ae1b025a9c5639e1ahumbedooh<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
9750e43c0e01cbb2cda812fef5f341de512f03f5rbowenif (typeof(prettyPrint) !== 'undefined') {
b686b6a420bde7f78c416b90be11db94cb789979nd prettyPrint();
b686b6a420bde7f78c416b90be11db94cb789979nd}
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd//--><!]]></script>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd</body></html>