HTTP URL Redirect

A RewriteRule is one way to redirect a request for a URL to a different page, which is called a URL redirect or URL forwarding. It is the recommended way to do a URL redirect for static web pages.

If you move a site, directory or one or more web pages you should create a URL redirect in the old location to automatically send users to the new location. To potentially preserve the page rank of those pages, it is recommended to create URL redirects on a one-to-one page-for-page basis (see Google Webmaster Central Help on "Moving Your Site"). In addition, the instructions in Google Webmaster Tools "Site configuration" - "Change of address" should be followed.

Although this also works for dynamically-generated pages it requires knowledge on how to code regular expressions.

When generating HTML with a program or server-side scripting, the language probably has an API to send the proper HTTP headers.

Regular Expression Metacharacters

Any regular expression metacharacters in the RewriteRule must be escaped with a backslash (\). These metacharacters that need to be escaped include:

See the URL Redirect Examples below for an example.