The UV SEO Series – Part Two – One Website Address

search In part one of "The UV SEO Series", I introduced the series and didn't get into anything specific. This is part two and the beginning of the onsite SEO portion of the series. It's longer than I anticipated so please, take your time.


One Website Address

How many ways can someone reach your website's home page? Do you, or do you not, use "www." in front of the domain name? Wouldn't it make sense to make sure the search engines, as well as people, can find your website at only one address?

What about your individual pages or posts? If you use pretty permalinks, do they all end with "/", just like the home page should? If your home page address starts with "www.", shouldn't the individual pages and posts start the same way?

The search engines are pretty good about indexing websites the way you intend, but why allow them to make mistakes? If you want a page to rank high in the SERPS, wouldn't it be easier if the page is being indexed with one address instead of two, three or four?

A few short months after I started this blog, I found my website listed by various search engines in four different ways:

  • untwistedvortex.com
  • untwistedvortex.com/
  • www.untwistedvortex.com
  • www.untwistedvortex.com/

I also found individual blog posts with either the trailing slash in place or not in place — two different URLs for each post. Would you believe that some addresses had higher rankings than the competing addresses? I believe one consistent format would have ranked better than all the different versions combined.

Most web servers automatically tack on the trailing slash, but not all of them. Most web servers also redirect to the appropriate page, with or without "www.", but then again, not all of them. I can't count how many broken links I've encountered due to server inconsistencies.

The simple solution is to make sure your website always points to the correct locations. The most popular website software packages either have this feature built in or the feature can be enabled with various plugins or add-ons. There are two other ways: The .htaccess file for web servers that support it or a simple PHP script.

The .htaccess code requires mod_rewrite to be turned on at the web server (it is on most). The code to force a redirection to the "www." or non-www version of the address looks like this:

Add www:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^untwistedvortex.com$
RewriteRule ^(.*)$ http://www.untwistedvortex.com/$1 [R=301,L]
</IfModule>

Remove www:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.untwistedvortex.com$
RewriteRule ^(.*)$ http://untwistedvortex.com/$1 [R=301,L]
</IfModule>

Here's the code to force a trailing slash. Insert it below the current "RewriteRule" above (use this only if your pages don't end with an extension):

RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]

This is a PHP script that will do it if you don't have .htaccess to work with. Insert it at the top of the page before anything else and un-comment the appropriate lines (and delete unused commented lines):

<?php
$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI'];

// to redirect to non-www URL
// if (substr($host,0,4) == 'www.') $url = substr($host,4);

// to redirect to www URL
// if (substr($host,0,4) != 'www.') $url = 'www.' . $host;

// remove home page from URL and force trailing slash
// change 'index.php' below to whatever your home page actually is
// if (strstr($uri, '/index.php') && substr($host, -1) != '/') $url = $host . '/';

// force trailing slash on individual pages (if extensions aren't used)
// if (strstr($uri, '/') && substr($uri,-1) != '/') $url .= '/';

header ("Location: http://$url,TRUE,301");
exit;
?>

Coming in Part Three

Part three will cover internal linking strategies. It may not seem important, but I'll point out more than one reason to develop a consistent internal linking strategy.

If you don't want to miss anything, make sure you subscribe to my daily, full articles by email.


Similar Posts:

10 Comments

  1. I have a plugin that I think handles the www part, but why the importance of trailing slash? Does that really make a difference?

    My latest blog post: Ask Jud Google Search

    • RT Cunningham says:

      It doesn't make a difference if your web server is behaving properly and whoever and whatever is trying to reach it can reach it. If there's a hiccup, for whatever reason, you want it accessible. You can choose to make either with or without the trailing slash, but you shouldn't rely on the web server alone to make it happen.

      When the Googlebot choked on one of my pages recently (it must have had a bad taste or something) it tried the page without a trailing slash AFTER instead of before the one with the trailing slash. I don't know about anyone else, but the faster they can index my pages (daily, by the way), the better I feel.

  2. hari says:

    The www is redundant. Most websites needn't use them, but due to historical reasons, most web servers are configured to provide that subdomain (yes, the www is a subdomain pointing to the default domain).

    Using rewriterule is a good idea as removing www is not a practical solution – most people tend to preface all website addresses with www.

    My latest blog post: Boxi and Panjo – Juvenile Humour

  3. Troy says:

    Found this little gem while going through my scores of unread Google Reader posts – a very useful and quick tutorial. I'll have to implement it on my own 3 URLs.

  4. YoYo says:

    Nice post…

    What about Windows 2003 ???
    or
    asp?

  5. Useful post. Usually i use method "Remove www", so other methods i will remember for future using. Thank you

    My latest blog post: Lake George New York

Leave a Reply