Saturday, August 17, 2013

How to solve canonical issue (www and non-www)

One of the most common problems do All Design & Developers, I see in websites is the same content being available at both the WWW and non-WWW versions of a domain. I’ve come upon this in nearly every website I’ve done an SEO audit for, and I see it every day when browsing the web. regardless of it being so prevalent, it is indeed a problem.

You can solve this issue By Redirect Using .htaccess

 Redirect Using .htaccess

If your site is hosted on Apache, you can redirect from the WWW to the non-WWW, or vice versa, with a few lines in your .htaccess file.

Redirect WWW to non-WWW:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(yourdomain\.com)?$

RewriteRule ^(.*)$$1 [R=301,L]

Redirect non-WWW to WWW:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(www\.yourdomain\.com)?$

RewriteRule ^(.*)$$1 [R=301,L]

Redirect Using cPanel: 

Another way is C-panel of website, you can go on website control panel and set www and non www setting. 

No comments:

Post a Comment