Search engine optimization for small and very small businesses.

3 Lines of Code Can Improve Your Rankings

HTML codeMany webmasters and web site owners aren’t aware of this hidden killer of search engine rankings. The problem occurs when multiple URLs can access the same page on your site. For example, all of the following are likely to point to the same page:

  • http://samplesite.com
  • http://www.samplesite.com
  • http://samplesite.com/index.html
  • http://www.samplesite.com/index.html

If other web sites link to yours 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. Your PageRank will be diluted by the fact that some links are going to different URLs for your page.

Do you have this problem? It’s easy to check. In your browser, navigate to www.yoursite.com (substituting your own domain, of course). Then go to yoursite.com (without the “www.”). If both go to the exact same URL (check the address box in your browser), then you’re in good shape. But if one displays your URL with the “www” and the other displays it without, then you have this problem.

How to Fix This

First, choose which version you want to use — with or without the www. Then, have your webmaster injsert the following at the beginning of your .htaccess file. (Don’t worry: your webmaster will know what that file is. Unfortunately, this only works if your site is hosted on a Unix or Linux server. If it’s hosted on a Windows server, your webmaster will have to check for the proper way to do this on your server.)

To use the with-www version of your site, use this code, substituting your domain as appropriate:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]

To use the without-www version of your site, use this (again substituting as appropriate):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yoursite.com
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]

That’s it! Just test to make sure it works.

Of course, you still need to make sure all the sites linking to yours are linking to the right version, and that if they’re linking to your home page they’re not including the actual page filename after the .com. But this little trick should take care of the worst of things.

1 Comment
  1. Great post. I’m facing many of these issues as well..

Leave a Reply