Rank Magic

3 Lines of Code Can Improve Your Rankings

Many 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. And just 3 lines of code can fix it.

For example, all of the following are likely to point to the same page:

If other websites 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 insert 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.

[Update Be sure to employ the same 3 lines of code when you migrate your site from an insecure “http://” prefix to a secure “https://” prefix.]
Exit mobile version