Redirecting your domain name to another domain is quite simple. But it can look really difficult for people who don’t know how to redirect a domain to another domain. Here is a tutorial to make you understand how to do it and what are difficulties while trying to redirect a domain to a completely diffrent domain.
What is Redirection of a Domain?
Redirection is simply moving your website visitors from one URL to another. Suppose you have a website at http://mywebsite.com. Now you don’t want to use this domain name anymore. You have started using a completely different domain which is http://example.com. Now what about the visitors who visit your website using the previous URL which is http://mywebsite.com. They won’t have anything to see asĀ you have started using a different domain ( http://example.com ).
It is surely not a good idea to leave visitors to your previous domain. The only way to keep this visitors is by redirecting them automatically to your new domain name. It means that when anyone enters your website using your previous URL, they will be automatically redirected to your new domain name and you will not loose your previous visitors.
How to redirect a domain?
There are a number of ways to redirect a domain to another domain. The best way is by using your website’s control panel. You can also contact your hosting provider to do it for you. Login to your website or blog’s control panel. You will surely find an option called ” Redirects ” to redirect a domain name to another. Actually, using the redirect function generates some codes in the .HTACCESS file of your website’s root folder. An .htaccess file is a source file whice is read everytime your webpages are accessed. The .htaccess file configurations tell your server how to present your webpage in front of the world. So using these codes in your .htaccess file is important to make it possible.
Now what if you don’t have the opportunity to use ” Redirect ” function. There are some web hosting companies that don’t make this function available in the control panel. In that case, you need to manually add the codes to your .htaccess file. Use the following codes to make redirections.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://example.com/$1 [R=301,L]
You just need to replace http://example.com with the your actual domain name where you want your visitors to be redirected. Remember that these codes has to be in the root folder of the domain you want to redirect. The above 301 redirect codes will work only on Linux servers having the Apache Mod-Rewrite moduled enabled. You can check this by contacting your server administrator. However, most popular web-hosting companies have this feature enabled. So you should not be having any problem.
Remember, 301 Permanent redirect is search engine friendly as you tell search engines that the location of your webpages has changed permanently. It helps search engines index your pages better. Making a 302 Tempory redirects most of the time, makes search engines confused. However, if you want to make this redirections temporary, you can use 302 instead of 301. However, 301 is recommened.
You can also use this codes to redirect your site from www version to non-www version and vice versa. Technically example.com and www.example.com are two completely different page although both provide the same content. Google might consider it duplications. So it is a better idea to choose a prefferred version of URL and stick with it. If you are using non-www version, you should redirect all www version URLs to non-www version permanently and also choose your preferred version of URL in Google Webmaster Tool. However, you can also use the following codes to make it possible if the previous one doesn’t work. Remember to replace example.com to your actual domain.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Remember, the root .htaccess file is an extremly important file for your website. Always backup your .htaccess file before making any changes to it. So if anything goes wrong, you can alway upload a fresh .htaccess file from the backup. While editing .htaccess file, be very careful about what you are doing and where you are putting your codes. Because when it comes to .htaccess file, every single space and sign matters a lot. For an example, just putting a slash ” / “ in a wrong place can break the entire configurations. So be careful and don’t make any changes without having proper knowledge.









