The directives contained in this module allow for manipulation
and control of URLs as requests arrive at the server. The
The
Aliases and Redirects occuring in different contexts are processed
like other directives according to standard merging rules. But when multiple
Aliases or Redirects occur in the same context (for example, in the
same
First, all Redirects are processed before Aliases are processed,
and therefore a request that matches a
For this reason, when two or more of these directives apply to the same sub-path, you must list the most specific path first in order for all the directives to have an effect. For example, the following configuration will work as expected:
But if the above two directives were reversed in order, the
/foo
/foo/bar
The
A request for http://myserver/image/foo.gif
would cause
the server to return the file /ftp/pub/image/foo.gif
. Only
complete path segments are matched, so the above alias would not match a
request for http://myserver/imagefoo.gif
. For more complex
matching using regular expressions, see the
Note that if you include a trailing / on the url-path then the server will require a trailing / in order to expand the alias. That is, if you use
Alias /icons/ /usr/local/apache/icons/
then the url /icons
will not be aliased.
Note that you may need to specify additional
In particular, if you are creating an Alias
to a
directory outside of your
This directive is equivalent to /icons
directory, one might
use:
The full range of
One subtle difference
between
In other words, just changing
^
to the beginning of the regular expression
and add (.*)$
to the end, and add $1
to
the end of the replacement.
For example, suppose you want to replace this with AliasMatch:
This is NOT equivalent - don't do this! This will send all requests that have /image/ anywhere in them to /ftp/pub/image/:
This is what you need to get the same effect:
Of course, there's no point in
using
The Redirect directive maps an old URL into a new one by asking the client to refetch the resource at the new location.
The old URL-path is a case-sensitive (%-decoded) path beginning with a slash. A relative path is not allowed.
The new URL may be either an absolute URL beginning with a scheme and hostname, or a URL-path beginning with a slash. In this latter case the scheme and hostname of the current server will be added.
Then any request beginning with URL-Path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-Path will be appended to the target URL.
If the client requests http://example.com/service/foo.txt
,
it will be told to access
http://foo2.example.com/service/foo.txt
instead. This includes requests with GET
parameters, such as
http://example.com/service/foo.pl?q=23&a=42
,
it will be redirected to
http://foo2.example.com/service/foo.pl?q=23&a=42
.
Note that POST
s will be discarded.
Only complete path segments are matched, so the above
example would not match a request for
http://example.com/servicefoo.txt
. For more complex matching
using regular expressions, see the
Redirect directives take precedence over Alias and ScriptAlias directives, irrespective of their ordering in the configuration file.
If no status argument is given, the redirect will be "temporary" (HTTP status 302). This indicates to the client that the resource has moved temporarily. The status argument can be used to return other HTTP status codes:
Other status codes can be returned by giving the numeric
status code as the value of status. If the status is
between 300 and 399, the URL argument must be present,
otherwise it must be omitted. Note that the status must be
known to the Apache code (see the function
send_error_response
in http_protocol.c).
This directive is equivalent to
The considerations related to the difference between
This directive makes the client know that the Redirect is
only temporary (status 302). Exactly equivalent to
Redirect temp
.
This directive makes the client know that the Redirect is
permanent (status 301). Exactly equivalent to Redirect
permanent
.
The
A request for http://myserver/cgi-bin/foo
would cause the
server to run the script /web/cgi-bin/foo
. This configuration
is essentially equivalent to:
In this scenario all files requested in /cgi-bin/
will be
handled by the file you have configured, this allows you to use your own custom
handler. You may want to use this as a wrapper for CGI so that you can add
content, or some other bespoke action.
This directive is equivalent to /cgi-bin
, one
might use:
As for AliasMatch, the full range of
The considerations related to the difference between