Many website owners have a small technical issue with their site(s) that they don’t even realize, and when left uncorrected, can severely hurt search engine rankings. This situation occurs when the one or more pages can be accessed via several different URL’s.
For example, the following URL’s may seem like they are the same page, but to a search engine, are actually different pages:
- http://samplesite.com
- http://www.samplesite.com
- http://samplesite.com/default.php
- http://www.samplesite.com/index.html
What are some of the issues you can face when this occurs?
If people link to your site inconsistently (which will happen sooner or later), different versions of the same pages can get indexed in search engines. This forces the search engines to choose the best URL to rank, or Canonical URL. It’s never a good idea to leave this decision up to search engines, because it can trigger the following problems that will hurt your rankings:
- Search engines attribute authority to a site based on the incoming links from other sites. Link juice or PageRank (the benefit of these inbound links) may be divided among different versions of a page instead of being allocated to just one page. This will cause one or more versions of a page to not rank as well as they could.
- Duplicate content issues can occur. Search engines may pick one page to rank and drop any others that carry identical/similar content.
You should be in control of what versions of your site and pages get indexed, and not leave it up to search engines to decide.
WWW vs. Non-WWW Versions of Your Site
Let’s take a look specifically at the first two examples from our list of URL’s above, the www and non-www versions of a site, because these are the most common, and easiest to fix.
- http://samplesite.com
- http://www.samplesite.com
In many aspects of ranking a site, search engines treat different subdomains on a site as if they were different domains entirely. Technically the www and non-www versions of your site are different subdomains, even though they have the same exact content.
If you do a search in Google, you’ll often see results where some have the www version and others have the non-www version of the same site. Not good. Regardless of whether these rank well or not, a site’s rankings can be improved by fixing this.
First take a look at your site, and see if you can access it via both http://www.yoursite.com and http://yoursite.com where yoursite.com is your domain name. If both versions end up at the same URL, then you’re fine and you don’t need to continue reading. However if both versions work, and neither redirects to the other, then read on.
Choose a Version
First, you need to pick a version of your site to use. Do you want people to visit http://yoursite.com or http://www.yoursite.com? There are good reasons to choose either one. The non-www version takes up less space and can offer more real estate on business cards, promotional materials, etc., but on the other hand, most people are trained to use the www version and will type that into a browser by default. Whatever you choose, be consistent in your usage, in everything from your site’s internal linking to your marketing collateral.
The Solution: 3 Lines of .Htaccess Code
There is a quick solution that most website owners shouldn’t have any problem implementing. The following is for sites on an Apache server, which most sites are. (If your site is on a Microsoft server, you’ll most likely have to ask your site administrator configure it to do the equivalent for you.)
First you will need to either edit, or create an .htaccess file. If you’re not familiar, .htaccess is an Apache configuration file that goes in the public root folder of your website (the same directory where your site’s index file is). If you already have an .htaccess file, back it up before making any edits. If you don’t have one, simply open any text editor (Notepad, TextEdit, etc.) or html editing program (Dreamweaver, etc.) and create a blank file named .htaccess. Be sure to leave at least one blank line at the end of the file.
To use the www version of your site, insert the following near the beginning of your .htaccess file (switch yoursite.com to your domain name):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite\.com
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]
To use the non-www version of your site, insert the following near the beginning of your .htaccess file (switch yoursite.com to your domain name):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
Then test it out and make sure it’s working the way you want it to. If everything looks good, you’re done!
Wasn’t that easy?