From: Joshua Slive This document explains the method in which Apache determines
-what filesystem location to serve a file from based on the
-URL of a request. This document explains how Apache determines the filesystem
+location from which to serve a file using the URL of a request.Mapping URLs to Filesystem Locations
-
In deciding what file to serve for a given request, Apache's
default behavior is to take the URL-Path for the request (the part of
-the URL following the first single slash) and add it to the end of the
+the URL following the hostname and port) and add it to the end of the
DocumentRoot specified in
your configuration files. Therefore, the files and directories
underneath the DocumentRoot
make up the basic document
@@ -80,22 +79,21 @@ content based on the requested IP address or hostname.
There are frequently circumstances where it is necessary to allow
-web access to parts of the filesystem which are not strictly
-underneath the DocumentRoot.
-Apache offers several different ways to accomplish this. On Unix
-systems, symbolic links can be used to bring other parts of the
-filesystem under the DocumentRoot
. For security reasons,
-symbolic links will only be followed if the Options setting for the relevant
-directory includes FollowSymLinks
or
-SymLinksIfOwnerMatch
.
DocumentRoot
. For security reasons, Apache will follow
+symbolic links only if the Options
+setting for the relevant directory includes
+FollowSymLinks
or SymLinksIfOwnerMatch
.
Alternatively, the Alias -directive can be used to map any part of the filesystem into the web +directive will map any part of the filesystem into the web space. For example, with
Alias /docs /var/web/
-
+
the URL http://www.example.com/docs/dir/file.html
will
be served from /var/web/dir/file.html
. The ScriptAlias directive works
the same way, with the additional effect that all content located at
the target path is treated as CGI scripts.
For situations where additional flexibility is required, the AliasMatch and For situations where you require additional flexibility, you can +use the AliasMatch and ScriptAliasMatch -directives can do powerful regular-expression based matching and substitution. For example,
@@ -128,19 +126,19 @@ accessed using URLs such as the following.http://www.example.com/~user/file.html
-For security reasons, it would be inappropriate to give direct +
For security reasons, it is inappropriate to give direct
access to a user's home directory from the web. Therefore, the UserDir directive is used to
-specify a directory underneath the user's home directory where web
-files will be located. Using the default setting of Userdir
-public_html
, the above URL would look for a file at a directory
-like /home/user/public_html/file.html
where the
-/home/user/ is the user's home directory as specified in
+href="mod/mod_userdir.html#userdir">UserDir directive
+specifies a directory underneath the user's home directory where web
+files are located. Using the default setting of Userdir
+public_html
, the above URL maps to a file at a directory
+like /home/user/public_html/file.html
where
+/home/user/
is the user's home directory as specified in
/etc/passwd
.
There are also several other forms of the Userdir
-directive which can be used on systems where /etc/passwd
-cannot be used to find the location of the home directory.
/etc/passwd
+does not contain the location of the home directory.
Some people find the "~" symbol (which is often encoded on the web
as %7e
) to be awkward and prefer to use an alternate
@@ -150,8 +148,8 @@ structured in a regular way, then it is possible to use the AliasMatch directive to
achieve the desired effect. For example, to make
http://www.example.com/upages/user/file.html
map to
-/home/user/public_html/file.html
, the following
-AliasMatch
directive can be used.
/home/user/public_html/file.html
, use the following
+AliasMatch
directive:
AliasMatch ^/upages/([^/]*)/?(.*) /home/$1/public_html/$2
@@ -159,41 +157,38 @@ AliasMatch ^/upages/([^/]*)/?(.*) /home/$1/public_html/$2
URL Redirection
-The configuration directives discussed in the above sections are
-used to tell Apache to get content from a specific place in the
-filesystem and return it to the client. Sometimes, it is desirable
-instead to inform the client that the content being requested is
-located at an different URL, and instruct the client to make a new
-request with the new URL. This is referred to as redirection
-and is implemented by the Redirect directive. For example,
-if the contents of the directory /foo/
under the
-DocumentRoot
have been moved to the new directory
-/bar/
, clients can instructed to request the content at
-the new location as follows.
+The configuration directives discussed in the above sections tell
+Apache to get content from a specific place in the filesystem and
+return it to the client. Sometimes, it is desirable instead to inform
+the client that the requested content is located at a different
+URL, and instruct the client to make a new request with the new URL.
+This is called redirection and is implemented by the
+Redirect directive. For
+example, if the contents of the directory /foo/
under the
+DocumentRoot
are moved to the new directory
+/bar/
, you can instruct clients to request the content at
+the new location as follows:
Redirect permanent
/foo/ http://www.example.com/bar/
This will redirect any URL-Path starting in /foo/
to
the same URL path on the www.example.com
server with
-/bar/
substituted for /foo/
. Note that
-clients can be redirected to any server, not only the origin
-server.
+/bar/
substituted for /foo/
. You can
+redirect clients to any server, not only the origin server.
Apache also provides a RedirectMatch directive
-which can be used for more complicated rewriting problems. For
-example, to redirect requests for the site home page to a different
-site, but leave all other requests alone, the following configuration
-can be used.
+for more complicated rewriting problems. For example, to redirect
+requests for the site home page to a different site, but leave all
+other requests alone, use the following configuration:
RedirectMatch permanent ^/$ http://www.example.com/startpage.html
Alternatively, to temporarily redirect all pages on a site to one
-particular page, the following configuration is useful.
+particular page, use the following:
RedirectMatch temp .* http://www.example.com/startpage.html
@@ -203,7 +198,7 @@ RedirectMatch temp .* http://www.example.com/startpage.html
When even more powerful substitution is required, the rewriting
engine provided by mod_rewrite can
-be useful. The directives provided by this module can use
+be useful. The directives provided by this module use
characteristics of the request such as browser type or source IP
address in deciding from where to serve content. In addition,
mod_rewrite can use external database files or programs to determine
@@ -223,7 +218,7 @@ to work, even though the resource is at a new location.
Another common cause of "File Not Found" errors is accidental
mistyping of URLs, either directly in the browser, or in HTML links.
-Apache provides the module mod_speling
+Apache provides the module mod_speling
(sic) to help with this problem. When this module is activated, it
will intercept "File Not Found" errors and look for a resource with a
similar filename. If one such file is found, mod_speling will send an
@@ -232,12 +227,12 @@ several "close" files are found, a list of available alternatives will
be presented to the client.
An especially useful feature of mod_speling, is that it will
-compare filenames without respect to case. This can be useful for
-systems where users are unaware of the case-sensitive nature of URLs
-and the unix filesystem. However, using mod_speling for anything more
-than the occasional URL correction can lead to additional load on the
-server, since each "incorrect" request is followed by a URL
-redirection and a new request from the client.
+compare filenames without respect to case. This can help systems
+where users are unaware of the case-sensitive nature of URLs and the
+unix filesystem. But using mod_speling for anything more than the
+occasional URL correction can place additional load on the server,
+since each "incorrect" request is followed by a URL redirection and a
+new request from the client.
If all attempts to locate the content fail, Apache returns an error
page with HTTP status code 404 (file not found). The appearance of
diff --git a/docs/manual/urlmapping.html.en b/docs/manual/urlmapping.html.en
index 47e4873162..bc023dae75 100755
--- a/docs/manual/urlmapping.html.en
+++ b/docs/manual/urlmapping.html.en
@@ -15,9 +15,8 @@
Mapping URLs to Filesystem Locations
-This document explains the method in which Apache determines
-what filesystem location to serve a file from based on the
-URL of a request.
+This document explains how Apache determines the filesystem
+location from which to serve a file using the URL of a request.
- DocumentRoot
@@ -63,7 +62,7 @@ URL of a request.
In deciding what file to serve for a given request, Apache's
default behavior is to take the URL-Path for the request (the part of
-the URL following the first single slash) and add it to the end of the
+the URL following the hostname and port) and add it to the end of the
DocumentRoot specified in
your configuration files. Therefore, the files and directories
underneath the DocumentRoot
make up the basic document
@@ -80,22 +79,21 @@ content based on the requested IP address or hostname.
Files Outside the DocumentRoot
There are frequently circumstances where it is necessary to allow
-web access to parts of the filesystem which are not strictly
-underneath the DocumentRoot.
-Apache offers several different ways to accomplish this. On Unix
-systems, symbolic links can be used to bring other parts of the
-filesystem under the DocumentRoot
. For security reasons,
-symbolic links will only be followed if the Options setting for the relevant
-directory includes FollowSymLinks
or
-SymLinksIfOwnerMatch
.
+web access to parts of the filesystem that are not strictly underneath
+the DocumentRoot. Apache
+offers several different ways to accomplish this. On Unix systems,
+symbolic links can bring other parts of the filesystem under the
+DocumentRoot
. For security reasons, Apache will follow
+symbolic links only if the Options
+setting for the relevant directory includes
+FollowSymLinks
or SymLinksIfOwnerMatch
.
Alternatively, the Alias
-directive can be used to map any part of the filesystem into the web
+directive will map any part of the filesystem into the web
space. For example, with
Alias /docs /var/web/
-
+
the URL http://www.example.com/docs/dir/file.html
will
be served from /var/web/dir/file.html
. The ScriptAlias directive works
the same way, with the additional effect that all content located at
the target path is treated as CGI scripts.
For situations where additional flexibility is required, the AliasMatch and For situations where you require additional flexibility, you can +use the AliasMatch and ScriptAliasMatch -directives can do powerful regular-expression based matching and substitution. For example,
@@ -128,19 +126,19 @@ accessed using URLs such as the following.http://www.example.com/~user/file.html
-For security reasons, it would be inappropriate to give direct +
For security reasons, it is inappropriate to give direct
access to a user's home directory from the web. Therefore, the UserDir directive is used to
-specify a directory underneath the user's home directory where web
-files will be located. Using the default setting of Userdir
-public_html
, the above URL would look for a file at a directory
-like /home/user/public_html/file.html
where the
-/home/user/ is the user's home directory as specified in
+href="mod/mod_userdir.html#userdir">UserDir directive
+specifies a directory underneath the user's home directory where web
+files are located. Using the default setting of Userdir
+public_html
, the above URL maps to a file at a directory
+like /home/user/public_html/file.html
where
+/home/user/
is the user's home directory as specified in
/etc/passwd
.
There are also several other forms of the Userdir
-directive which can be used on systems where /etc/passwd
-cannot be used to find the location of the home directory.
/etc/passwd
+does not contain the location of the home directory.
Some people find the "~" symbol (which is often encoded on the web
as %7e
) to be awkward and prefer to use an alternate
@@ -150,8 +148,8 @@ structured in a regular way, then it is possible to use the AliasMatch directive to
achieve the desired effect. For example, to make
http://www.example.com/upages/user/file.html
map to
-/home/user/public_html/file.html
, the following
-AliasMatch
directive can be used.
/home/user/public_html/file.html
, use the following
+AliasMatch
directive:
AliasMatch ^/upages/([^/]*)/?(.*) /home/$1/public_html/$2
@@ -159,41 +157,38 @@ AliasMatch ^/upages/([^/]*)/?(.*) /home/$1/public_html/$2
URL Redirection
-The configuration directives discussed in the above sections are
-used to tell Apache to get content from a specific place in the
-filesystem and return it to the client. Sometimes, it is desirable
-instead to inform the client that the content being requested is
-located at an different URL, and instruct the client to make a new
-request with the new URL. This is referred to as redirection
-and is implemented by the Redirect directive. For example,
-if the contents of the directory /foo/
under the
-DocumentRoot
have been moved to the new directory
-/bar/
, clients can instructed to request the content at
-the new location as follows.
+The configuration directives discussed in the above sections tell
+Apache to get content from a specific place in the filesystem and
+return it to the client. Sometimes, it is desirable instead to inform
+the client that the requested content is located at a different
+URL, and instruct the client to make a new request with the new URL.
+This is called redirection and is implemented by the
+Redirect directive. For
+example, if the contents of the directory /foo/
under the
+DocumentRoot
are moved to the new directory
+/bar/
, you can instruct clients to request the content at
+the new location as follows:
Redirect permanent
/foo/ http://www.example.com/bar/
This will redirect any URL-Path starting in /foo/
to
the same URL path on the www.example.com
server with
-/bar/
substituted for /foo/
. Note that
-clients can be redirected to any server, not only the origin
-server.
+/bar/
substituted for /foo/
. You can
+redirect clients to any server, not only the origin server.
Apache also provides a RedirectMatch directive
-which can be used for more complicated rewriting problems. For
-example, to redirect requests for the site home page to a different
-site, but leave all other requests alone, the following configuration
-can be used.
+for more complicated rewriting problems. For example, to redirect
+requests for the site home page to a different site, but leave all
+other requests alone, use the following configuration:
RedirectMatch permanent ^/$ http://www.example.com/startpage.html
Alternatively, to temporarily redirect all pages on a site to one
-particular page, the following configuration is useful.
+particular page, use the following:
RedirectMatch temp .* http://www.example.com/startpage.html
@@ -203,7 +198,7 @@ RedirectMatch temp .* http://www.example.com/startpage.html
When even more powerful substitution is required, the rewriting
engine provided by mod_rewrite can
-be useful. The directives provided by this module can use
+be useful. The directives provided by this module use
characteristics of the request such as browser type or source IP
address in deciding from where to serve content. In addition,
mod_rewrite can use external database files or programs to determine
@@ -223,7 +218,7 @@ to work, even though the resource is at a new location.
Another common cause of "File Not Found" errors is accidental
mistyping of URLs, either directly in the browser, or in HTML links.
-Apache provides the module mod_speling
+Apache provides the module mod_speling
(sic) to help with this problem. When this module is activated, it
will intercept "File Not Found" errors and look for a resource with a
similar filename. If one such file is found, mod_speling will send an
@@ -232,12 +227,12 @@ several "close" files are found, a list of available alternatives will
be presented to the client.
An especially useful feature of mod_speling, is that it will
-compare filenames without respect to case. This can be useful for
-systems where users are unaware of the case-sensitive nature of URLs
-and the unix filesystem. However, using mod_speling for anything more
-than the occasional URL correction can lead to additional load on the
-server, since each "incorrect" request is followed by a URL
-redirection and a new request from the client.
+compare filenames without respect to case. This can help systems
+where users are unaware of the case-sensitive nature of URLs and the
+unix filesystem. But using mod_speling for anything more than the
+occasional URL correction can place additional load on the server,
+since each "incorrect" request is followed by a URL redirection and a
+new request from the client.
If all attempts to locate the content fail, Apache returns an error
page with HTTP status code 404 (file not found). The appearance of