The index of a directory can come from one of two sources:
index.html
. The The two functions are separated so that you can completely remove (or replace) automatic index generation should you want to.
A "trailing slash" redirect is issued when the server
receives a request for a URL
http://servername/foo/dirname
where
dirname
is a directory. Directories require a
trailing slash, so http://servername/foo/dirname/
.
The Indexes
option is
set, the server will generate its own listing of the
directory.
then a request for http://example.com/docs/
would
return http://example.com/docs/index.html
if it
exists, or would list the directory if it did not.
Note that the documents do not need to be relative to the directory;
would cause the CGI script /cgi-bin/index.pl
to be
executed if neither index.html
or index.txt
existed in a directory.
A single argument of "disabled" prevents
Note: Multiple
By default, the
The argument can be:
on
: issues a 302 redirection to the index resource.off
: does not issue a redirection. This is the legacy behaviour of mod_dir.permanent
: issues a 301 (permanent) redirection to the index resource.temp
: this has the same effect as on
seeother
: issues a 303 redirection (also known as "See Other") to the index resource.A request for http://example.com/docs/
would
return a temporary redirect to http://example.com/docs/index.html
if it exists.
The
Typically if a user requests a resource without a trailing slash, which
points to a directory,
If you don't want this effect and 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.
Turning off the trailing slash redirect may result in an information
disclosure. Consider a situation where Options +Indexes
) and index.html
) and there's no other special handler defined for
that URL. In this case a request with a trailing slash would show the
index.html
file. But a request without trailing slash
would list the directory contents.
Also note that some browsers may erroneously change POST requests into GET (thus discarding POST data) when a redirect is issued.
disabled
argument is available in version 2.4.4 and
laterUse 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
will cause requests for non-existent files to be handled by
not-404.php
, while requests for files that exist
are unaffected.
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.'
In earlier versions of httpd, this effect typically required
-f
and
-d
tests for file and directory existence. This now
requires only one line of configuration.
Existing files, such as images, css files, and so on, will be served normally.
Use the disabled
argument to disable that feature
if inheritance from a parent directory is not desired.
In a sub-URI, such as http://example.com/blog/ this sub-URI has to be supplied as local-url:
A fallback handler (in the above case, /blog/index.php
)
can access the original requested URL via the server variable
REQUEST_URI
. For example, to access this variable in PHP,
use $_SERVER['REQUEST_URI']
.
The
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