Change of Domain 301 Redirect htaccess

Friday, October 12, 2012



For SEO best practices, when you change domain name of existing website, we need to setup 301 redirect of all existing web pages exactly to a new domain name. This is very important for Search engines detect a new version of URLs

Using the following htaccess code we will redirect all the existing pages of our website to new.


RewriteEngine On
# Redirect all urls with new domain name
RewriteCond %{HTTP_HOST} ^domainone.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domainone.com$
RewriteRule ^(.*)$ http://www.domaintwo.com/$1 [r=301,nc]

# Redirect with www of new domain.
RewriteCond %{http_host} ^domaintwo.com [nc]
RewriteRule ^(.*)$ http://www.domaintwo.com/$1 [r=301,nc]

about code will redirect all the existing pages of current website to new website with same request URL.

No comments:

Post a Comment