WHY IT IS IMPORTANT?

Having two different versions of URL for the same page i.e. yourdomain.com and www.yourdomain.com is considered as the duplicating the same content on two different web pages. Duplicate content ( after the Panda Update of Google) lead to penalty and your website may disappear from SERP. WHY? This is what the entire search engine algorithm are designed with. All the search engine bots are programmed to consider all the unique URLs as a different entity. They do not have functionality to correlate 2 different versions of the same or different URLs until you (the webmaster of website) mention that.

HOW TO DO IT?

STEP 1: Login to your website control Panel, i.e. cPanel
STEP 2: Go to the FILES category and click on File Manager.
STEP 3: A popup will open asking you what Directory you want to go to. Check the Web Root radio button and also check the check box displaying Show Hidden Files (dotfiles).
STEP 4: Here you can see a file named .htaccess. Select this file and click on Edit button placed at top right navigation. A popup will open asking about the encoding, simply click on Edit again.
STEP 5: Now a text editor will open the .htaccess file, place the below code as per your requirement in the file. Click on Save Changes

TO REDIRECT ON WWW.YOURDOMAIN.COM

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301,NC]

TO REDIRECT ON YOURDOMAIN.COM

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

Note: Replace yourdomain.com with the domain name that wish to redirect. Use either of the code else the redirect will stuck in infinite loop and you’ll see error. Remove the First Line of Code if you see RewriteEngine on is already there in your htaccess file.

Leave a Reply