Migration of domain name is a big exercise if you want to retain the goodwill of your old domain. Especially those who are looking to:
- Retain their page rankings
- Retain the traffic that is coming when organic search is done.
- Retain the traffic coming because of back linking to your old domain. (I am assuming that you still own the old domain. If that's not the case than this post is not valid)
Before we see how we can do an intelligent domain migration, be comfortable with the concept of
Redirection. For details you can check here
Redirection. For details you can check here
There are multiple ways to do redirection. The most popular way is to use .htaccess file from web server. Usually Apache is the most popular web server that you might encounter.
.htaccess stands for Hypertext access and is kept at the root of your web site root. Please be careful in dealing with this file.
Once you get hold of the .htaccess file, open it in an editor. Also check if you are using some hosting provider and have cpanel, you need not have to deal with .htaccess file directly as these hosting providers through cpanel UI give the facility to redirect the domains.
Now on the .htaccess file, at the top write this
RewriteEngine on
After that you need to tell which url will be redirected to which url
for example if you want to redirect http://www.olddomain.webabc to http://www.newdomain.webxyz
Also you want the old domain to be transferred with or without www
RewriteCond %{HTTP_HOST} ^olddomain\.webabc$
[OR]
RewriteCond %{HTTP_HOST}
^www\.olddomain\.webabc\.com$
RewriteRule ^/?$
"http\:\/\/www\.newdomain\.webxyz\/" [R=301,L]
Let's look into each section of RewriteCond and RewriteRule
RewriteCond
RewriteCond %{HTTP_HOST} ^olddomain\.webabc$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.webabc\.com$
This basically says that any request to old domain with or without www. Note the [OR]
RewriteRule
RewriteRule ^/?$ "http\:\/\/www\.newdomain\.webxyz\/" [R=301,L]
In rewrite rule there are two parts. The first part /? says there is zero of one of the element. after http://www.olddomain.webabc/. The second part tells the url where it is migrated. While reading it ignore \ as this is an indication to the server.
The last part is [R=301,L] . It means that it is a permanent redirection (301) and it is the last rule for the condition. If you are migrating your domain permanently than you might just want to repeat [R=301,L] as it is.
Let's look into another example of redirecting a URL of http://www.olddomain.webabc/oldcontent to http://www.newdomain.webxyz/newcontent
The rule will be written as
RewriteCond %{HTTP_HOST} ^olddomain\.webabc$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.webabc\.com$
RewriteRule ^oldcontent$ "http\:\/\/www\.newdomain\.webxyz\/newcontent" [R=301,L]
If you want to see all the gory details you might want to check the Apache docs on mod_rewrite
If you have a customized environment then you might want to write a program which sits on the front of your website/web application and listens to HTTP traffic and redirects the traffic to new url.
No comments:
Post a Comment