The directives contained in this module allow for manipulation
and control of URLs as requests arrive at the server. The
The
When the
Aliases and Redirects occurring 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
When the
The
A request for http://example.com/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://example.com/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
then the URL /icons
will not be aliased, as it lacks
that trailing /. Likewise, if you omit the slash on the
URL-path then you must also omit it from the
file-path.
Note that you may need to specify additional
In particular, if you are creating an Alias
to a
directory outside of your
Any number slashes in the URL-path parameter matches any number of slashes in the requested URL-path.
If the
This syntax is available in Apache 2.4.19 and later.
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
Multiple leading slashes in the requested URL are discarded by the server before directives from this module compares against the requested URL-path.
The
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 if you have
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 the expression syntax, omit the URL-path
argument as described below. Alternatively, for matching using regular
expressions, see the
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.
If the status is not between 300 and 399, the
URL argument must be omitted. The status must be a valid
HTTP status code, known to the Apache HTTP Server (see the function
send_error_response
in http_protocol.c).
If the
This syntax is available in Apache 2.4.19 and later.
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://example.com/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.
If the
This syntax is available in Apache 2.4.19 and later.
This directive is equivalent to /cgi-bin
, one
might use:
As for AliasMatch, the full range of
The considerations related to the difference between
By default, if the target URL of a