Using Htaccess to Forward Visitors to New Domain Name

Related to my previous post (moving web site to the new domain), here’s how you can forward all visitors to your new site using .htaccess (for Apache web server):

1
2
3
4
RewriteEngine on

RewriteCond %{HTTP_HOST} ^olddomain.com
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=permanent,L]

This will forward all visitors to your new domain, targeting exactly the same document as requested on the olddomain. This redirect will have permanent redirection status so search engines should hopefully cope with it too.

Comments