Friday, October 12, 2012

Change of Domain 301 Redirect htaccess

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} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [r=301,nc]

# Redirect with www of new domain.
RewriteCond %{http_host} ^ [nc]
RewriteRule ^(.*)$$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