Name
Redirect
Synopsis
Redirect [status] url-path url Server config, virtual host, directory, .htaccess
The Redirect
directive maps an old URL into a new
one. The new URL is returned to the client, which attempts to fetch
the information again from the new address.
url-path
is a (%-decoded) path; any requests for
documents beginning with this path will be returned a redirect error
to a new (%-encoded) URL beginning with url
.
Example
Redirect /service http://foo2.bar.com/service
If the client requests http://myserver/service/foo.txt, it will be told to access http://foo2.bar.com/service/foo.txt instead.
Tip
Redirect
directives take precedence over
Alias
and ScriptAlias
directives, irrespective of their ordering in the configuration file.
Also, url-path
must be an absolute path, not a
relative path, even when used with .htaccess
files or inside of <Directory>
sections.
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:
-
permanent
Returns a permanent redirect status (301) indicating that the resource has moved permanently.
-
temp
Returns a temporary redirect status (302). This is the default.
-
seeother
Returns a “See Other” status (303) indicating that the resource has been replaced.
-
gone
Returns a “Gone” status (410) indicating that the resource has been permanently removed. When this status is used, the
url
argument ...
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.