Wednesday, October 28, 2009

Apache: .htaccess redirection

If you want visitors of your old website domain to be redirected to
the new domain, use the following code in .htaccess file placed in the
document root of your old website.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

This way, visitors of

http://olddomain.com/some_file.html
will be redirected to
http://www.newdomain.com/some_file.html

No comments: