URL Redirection - Techniques - HTTP Status Codes 3xx - Apache Mod_rewrite

Apache Mod_rewrite

The Apache HTTP Server's mod_alias extension can be used to redirect certain requests. Typical configuration directives look like:

Redirect permanent /oldpage.html http://www.example.com/newpage.html Redirect 301 /oldpage.html http://www.example.com/newpage.html

For more flexible URL rewriting and redirection, Apache mod_rewrite can be used. E.g. to redirect a requests to a canonical domain name:

RewriteEngine on RewriteCond %{HTTP_HOST} ^(+.)*oldsite.example.com.?(:*)?$ RewriteRule ^(.*)$ http://newsite.example.net/$1

Such configuration can be applied to one or all sites on the server through the server configuration files or to a single content directory through a .htaccess file.

Read more about this topic:  URL Redirection, Techniques, HTTP Status Codes 3xx

Famous quotes containing the word apache:

    The Apache have a legend that the coyote brought them fire and that the bear in his hibernations communes with the spirits of the “overworld” and later imparts the wisdom gained thereby to the medicine men.
    —Administration in the State of Arizona, U.S. public relief program (1935-1943)