“Give them quality. That’s the best kind of advertising,” - Milton Hershey

Redirecting non-www to www .htaccess

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.

SUBSCRIBE HERE VIA EMAIL TO GET MORE UPDATES

Enter your email address:

About Ravi

My name is Ravi, I'm a internet marketing professional from India. I'm a author of SEO Education. I hope we can share our knowledge and lots of information, tips, ideas & experiences here. Also you can follow me on Twitter & Facebook. Here is my personal website datti.net. Keep in touch ravi.datti@gmail.com.

Comments

  1. thanks…this is valuable information for me…

  2. 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

  3. thanks man for the information

  4. Thanks for the explanations.Please give me more explanations about .htaccess.

  5. Thanks for share a nice post

  6. Thanks for the simple and neat explanation.can you please also explain mobile redirects.

Speak Your Mind

*


− two = 1