4.5 Redirecting Visitors to an Alternate URL

URL forwarding is a method for the Web server to tell a user that a URL has changed—for example, if you have moved files to another directory or server. You can also use redirection to send a person who requests a document on one server to a document on another server.

To map a URL to another server, you must first specify the prefix of the URL you want the server to redirect. Then, you need to choose which URL to redirect to. You can redirect to a URL prefix if the directory on the new server is the same as in the mapped URL; you can also redirect to a fixed URL (hostname, directory, and filename).

The URL Forwarding page in Apache Manager enables you to set up a home directory for each of your users.

Figure 4-3 Apache URL Forwarding

URL Forwarding page
  1. In the URL Prefix field, type the portion of the old URL to be forwarded.

  2. In the Forward Requests To field, type the URL where requests should be forwarded to.

  3. Click Save > Save to save your changes.

    or

    Click Save > Save and Apply to save your changes and restart Apache so your changes are immediately put into effect.

    For information about where configuration information is stored, see Section 2.3.3, Saving Configuration Changes and Restarting Apache in Apache Manager.

If you forward to a URL prefix, the forwarding keeps the full pathname and substitutes one prefix for another. For example, if you forward http://www.digitalairlines.com/info/docs to a prefix cambridge.com, the URL http://www.digitalairlines.com/info/docs redirects to http://cambridge.com/info/docs.

However, if the directory structure on the new server is not the same as in the mapped URL, you could forward the URL to a fixed URL. For example, you could forward http://www.digitalairlines.com/info/docs to http://cambridge.com/new-files/info/docs.

Sometimes you might want to redirect requests for all the documents in one subdirectory to a specific URL. For example, if you removed a directory because it was causing too much traffic or because the documents were no longer to be served for any reason, you could direct a request for any one of the documents to a page explaining why the documents were no longer available. For example, a prefix on /info/docs could be redirected to http://www.digitalairlines.com/explain.html.

For more information, see the Redirect and Alias directives on the Apache Web site.

Also, for more information about general issues surrounding URL redirection, see the URL Rewriting Guide on the Apache Web site.