5.7. Redirecting to Another Location
Problem
You want requests to a particular URL to be redirected to another server.
Solution
Use a Redirect directive in httpd.conf, and give an absolute URL on the second argument:
Redirect "/example" "http://www2.example.com/new/location"
Discussion
Whereas Alias maps a URL to something in the local filesystem, Redirect maps a URL to another URL, usually on another server. The second argument is a full URL and is sent back to the client (browser), which makes a second request for the new URL.
It is also important to know that the Redirect directive preserves path information, if there is any. Therefore, this recipe redirects a request for http://original.example.com/example/something.html to http://other.example.com/new/location/something.html.
Redirections come in several different flavors, too; you can
specify which particular type of redirect you want to use by inserting
the appropriate keyword between the Redirect directive and the first URL
argument. All redirects instruct the client where the requested
document is now; the different types of
redirection inform where the client should look for the document in
the future. If no keyword is specified, the temp meaning is used by default:
tempA
temporaryredirection is used when the document is not in the originally requested location at the moment, but is expected to be there again some time in the future. So the client remembers the URL it used on the original request and will use it on future requests ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access