How 3 Lines of Code Improve Rankings

Get Help With All Aspects of Web Design & Design Software

Moderators: Moderator, Global Moderator

Post Reply
Tami
Administrator
Administrator
Posts: 10892
Joined: Sun Apr 25, 2004 1:05 pm

How 3 Lines of Code Improve Rankings

Post by Tami »

Article Written by Scott Allen
Source: [url=\"http://www.searchengineguide.com/scott-allen/how-3-lines-of-code-can-improve-your-rankings.php\"]Search Engine Guide[/url]

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:

[code] * http://samplesite.com
* http://www.samplesite.com
* http://samplesite.com/default.php
* http://www.samplesite.com/index.html[/code]

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.

[code] * http://samplesite.com
* http://www.samplesite.com[/code]

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 [url=\"http://www.yoursite.com\"]http://www.yoursite.com[/url] and [url=\"http://yoursite.com\"]http://yoursite.com[/url] 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 [url=\"http://yoursite.com\"]http://yoursite.com[/url] or [url=\"http://www.yoursite.com\"]http://www.yoursite.com[/url]? 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):
[code]RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite\.com
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L][/code]

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):
[code]RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L][/code]

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?
----

[url=\"http://www.searchengineguide.com/scott-allen/\"]More articles by Scott Allen[/url]
Image

[color=\"#41211C\"]It takes years to build up trust and only seconds to destroy it

[/color]
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 2:54 pm

How 3 Lines of Code Improve Rankings

Post by Josh »

I would have never even thought of this... Thanks for posting the article *goes to do a few minor edits on some websites* rofl <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Jim
Administrator
Administrator
Posts: 1324
Joined: Thu Jun 17, 2004 12:37 am

How 3 Lines of Code Improve Rankings

Post by Jim »

you can also use something like

[code]RewriteCond %{HTTP_HOST} ^somesite.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.somesite.net$
RewriteRule ^/?$ http://somesite.net/somedirectory [R=302,L][/code]

I have been using this to redirect everyone from my home directory to /blog/ >.>
Last edited by Jim on Tue May 06, 2008 1:31 am, edited 1 time in total.
Love is all a matter of timing.

It's no good meeting the right person too soon or too late.

If I'd live in another time or place...

...my story might have had a very different ending.
Wayne
Sr. Member
Sr. Member
Posts: 362
Joined: Thu Jun 17, 2004 12:37 am

How 3 Lines of Code Improve Rankings

Post by Wayne »

wow.... so I did a good thing by forwarding the domain.com to the www.domain.com in the beginning of the site creation! woohoo <img src=\'http://www.killanet.net/forum3/public/s ... /smile.gif\' class=\'bbc_emoticon\' alt=\':)\' />
ner0
Hero Member
Hero Member
Posts: 982
Joined: Sat May 22, 2004 4:45 pm

How 3 Lines of Code Improve Rankings

Post by ner0 »

that was a good read, useful tip <img src=\'http://www.killanet.net/forum3/public/s ... iggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' />
[color=\"green\"]'class KPIM::ProcessManager' only defines private constructors and has no friends[/color] <- :( poor class



[18:09:00] * ~Moppy stews ner0 erotically 1 times.
Post Reply

Return to “Web Design Principles”