Here I would like to explain about how to redirect non-www website url to www, usually Google treats non-www and www URLs as two different domains. We recommend to redirect your website from non-www to www URL. Make sure to redirect all main pages in the website should be redirected to www version to avoid duplicate and canonical issues.
Here is the procedure to overcome this problem, add below code to your .htaccess file.
Replace domain.com and update with your website url in following code.
Redirect non-www to www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
Redirect www to non-www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain\.com [NC]
RewriteRule (.*) http://domain.com/$1 [L,R=301]
Any suggestions or questions please feel free to update me through below comment box. Thanks for your visit and valuable comments.
thanks…this is valuable information for me…
Hai i have one website, i need redirect formula. you told above but i can’t understand kindly can explain briefly because i need this answers
Lots of redirection methods are there, Its depends on the our redirection plan, Can you please elaborate regarding your redirection problem, so that i can suggest you better.
thanks man for the information
Thanks for the explanations.Please give me more explanations about .htaccess.
Thanks for share a nice post
Thanks for the simple and neat explanation.can you please also explain mobile redirects.