Most websites are setup to allow access via either www or non-www. Example:
orCode:vbseo.com
However - this can lead to duplication of your content or redundant URLs within the search engines.Code:www.vbseo.com
For best SEO, you need to choose one version or the other, to ensure full link consistency and consensus, and to maximum crawling efficiency.
There are 2 methods of specify which version to use. One is by using your .htaccess file. The second way is to select your preferred format within Google Webmaster Tools.
Choosing to Use the WWW version of your domain ONLY
Edit your .htaccess file.
At the top, add the following new lines:
Note: You must replace example.com with your own site URL.Code:RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Once your new .htaccess file is uploaded to the server, your site will ONLY be accessible via the WWW version of your domain.
Anytime a user or search engine tries to access the non-WWW version of your site, they will be automatically forwarded to the WWW version.
Choosing to Use the NON-WWW version of your domain ONLY
- Edit your .htaccess file.
- At the top, add the following new lines:
Note: You must replace example.com with your own site URL.Code:RewriteCond %{HTTP_HOST} !^example\.com$ RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Once your new .htaccess file is uploaded to the server, your site will ONLY be accessible via the NON-WWW version of your domain.
Any time a user or search engine tries to access the WWW version of your site, they will be automatically forwarded to the NON-WWW version.
Making Exceptions
As this will only allow 1 way in, some times an exception must be made for other subdomains. If you need to allow an exception (ie, for a CDN), you can use an 'or' statement, you can do so by replacing
www:
withCode:RewriteCond %{HTTP_HOST} !^www\.example\.com$
non-www:Code:RewriteCond %{HTTP_HOST} !(^www\.example\.com$|^cdn\.example\.com$)
withCode:RewriteCond %{HTTP_HOST} !^example\.com$
where | denotes the 'or' case.Code:RewriteCond %{HTTP_HOST} !(^example\.com$|^cdn\.example\.com$)
Your CDN subdomain should be blocked via robots.txt at the CDN level. You cannot add it to your local robots file.
Choosing WWW or NON-WWW version of your domain in Google Webmaster Tools
If you are not yet using Google Webmaster Tools, you should be. It provides a wealth of info on how to improve your site for SEO purposes.
Here is a primer on some of the key aspects you should be evaluating with your account:
Google Webmaster Tools - Recommended for All vBSEO Customers
To specify which version of your domain to use, login to your account and go to the following section:
Go to Dashboard > Tools > Set preferred domain
Associate a preferred domain with this site, to always or never show the leading "www." in Google's search results.
Google will then ONLY list the WWW or NON-WWW version of your URLs in the index, whichever you select.
Lighttpd Webserver
Choosing to Use the WWW version of your domain ONLY
Please add the following rule to your lighttpd.conf file. In order to edit lighttpd.conf you can use the following command.
After editing lighttpd.conf using the vi editor, please save it and restart lighttpd.Code:# vi /etc/lighttpd/lighttpd.conf
You can restart lighttpd with the following commands.Code:$HTTP["host"] =~ "^domain\.com$" { url.redirect = ( "^/(.*)" => "http://www.domain.com/$1" ) }
Note: You must replace domain.com with your own site URL.Code:# service lighttpd restart # /etc/init.d/lighttpd restart
Choosing to Use the NON-WWW version of your domain ONLY
Please add the following rule to your lighttpd.conf file. In order to edit lighttpd.conf you can use the following command.
After editing lighttpd.conf via the vi editor, please save your lighttpd.conf and restart lighttpd.Code:# vi /etc/lighttpd/lighttpd.conf
You can restart lighttpd with the following commands.Code:$HTTP["host"] =~ "^www\.(.*)" { url.redirect = ( "^/(.*)" => "http://%1/$1" ) }
Note: You must replace domain.com with your own site URL.Code:# service lighttpd restart # /etc/init.d/lighttpd restart



3Likes
LinkBack URL
About LinkBacks





Reply With Quote


