Making Communications Buzz

Thursday, January 25, 2007

"www" in a website address: Why it matters to website success - continued

Here is a follow-up to my post about why "www" in front of your domain matters to the rank of your website in search engines like Google, Yahoo and MSN ("www" in a website address: Why it matters to website success).

If you want the code to use on your website host server to change all incoming requests for URLs without the "www" into URLs with the "www", simply put the following into your .htaccess file. The first 2 lines are a comment to remind you what the code is for.

# If an address without the "www." prefix is entered,
# this will redirect to the page with the "www." prefix.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# That's it!

Here is a good resource on .htaccess files:
http://encyclopedia.thefreedictionary.com/htaccess


Also, remember to change other settings and code on your website that involve the domain and whether it has "www" in it or not.

For example, WordPress blog software users should be sure to make the following changes.

Before adding the above code to the .htaccess file, WordPress users must be sure to login to their blog admin panel and go to Options > General.

Under *WordPress address (URI)* enter the address with "www." in front if it is not already there.

Likewise for the *Blog address (URI)*.

If these addresses don't have "www." in them, the .htaccess rewrite will cause an error. Other blog software, such as Typepad, is likely to require a similar change.

("URL" stands for Universal Resource Locator and "URI" stands for Universal Resource Indicator". For most purposes, the two terms are interchangeable: both mean "web address".)

If you use Google Site Search, you will need to make sure that the domain used in the Site Search code has "www" in it.

After adding the rewrite code to my .htaccess file, Google Site Search I use on McBuzz.com at http://www.mcbuzz.com/search.shtml did not work. The results page was blank. To make it work again, I went into the HTML and changed
input type="hidden" name="domains" value="mcbuzz.com"
to
input type="hidden" name="domains" value="www.mcbuzz.com"

The fact that Google Site Search requires the "www" is further evidence, it seems to me, of the importance of standardizing your URL to include "www". (You could try to standardize it to not include "www", but that seems -- well, not as standard, and thus harder to implement.)

If you have questions or comments about using the .htaccess file, or about the importance of standardizing your domain as either "www.example.com" or "example.com", please post your comment below or contact me through the McBuzz Communications website.

Looking forward to hearing from you!

Labels: , , , , ,