The URL redirection is an advance feature that allows you to use several directives (methods) for the redirection.
- Redirect Directive – The Redirect directive maps a requested URL into a new one by asking the web client to re-fetch the resource to the new location.
- RedirectMatch Directive – The RedirectMatch directive maps a Request-URL into a new one by making use of standard regular expressions, instead of simple prefix matching. The supplied regular expression is matched against the URL-path, and if it matches, the server substitutes any parenthesized matches into the given string and use it as a filename.
For example, to redirect all GIF files to like-named JPEG files on another server, you might use:
Regular Expression: (.*).gif$
RedirectMatch URL: http://www.anotherserver.com$1.jpg
Also, if you want to redirect all GIF files to picture.gif on another server, you might use:
Regular Expression: .gif$
RedirectMatch URL: http://www.anotherserver.com/picture.gif