DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 5.9 Redirecting Several URLs to the Same Destination

Problem

You want to redirect a number of URLs to the same place. For example, you want to redirect requests for /fish and /Fishing to http://fish.example.com/.

Solution

Use RedirectMatch in httpd.conf to match against a regular expression:

RedirectMatch ^/[fF]ish(ing)? http://fish.example.com

Discussion

This recipe redirects requests on one server for URLs starting with fish or fishing, with either an upper-case or lower-case f, to a URL on another server, fish.example.com. As with Redirect, the path information, if any, is preserved. That is, a request for http://original.server/Fishing/tackle.html is redirected to http://fish.example.com/tackle.html so that existing relative links continue to work.

As with several of the earlier examples, RedirectMatch uses regular expressions to provide arbitrary text pattern matching.

See Also

    [ Team LiB ] Previous Section Next Section