A HIPPO Internet Marketing Training blog by Corey Creed

The Jungle Map, your guide through internet marketing

Fix WordPress www and non-www issue! (Here’s how)

March 27th, 2007

The last few weeks, I’ve put some time into cleaning up and working with my own sites in order to optimize them for search engines.  In particular, I’ve been doing the following:

  • Add a Robots.txt
  • Add a .htaccess file (to prevent the www and non-www issue)
  • Installing our new logo in the header
  • Create a XML sitemap for each site
  • Submit the sitemap to Google and Yahoo

This is all baseline stuff for SEO.  It’s kind of embarrassing that I’ve never done it for my sites as I’ve done it for all my clients’ sites.

At any rate, these things are generally pretty simple to do.  But when it comes to a WordPress blog, everything is just a little different.  The good news is that there are plugins for WordPress that will do practically anything you want.  For example, let me explain the “www and non-www issue”.

What is the “www and non-www issue”?

This seems like a silly issue, but it is true and can actually cause problems with the search engines.

To illustrate, up until last week, this site could be seen by typing in www.TheJungleMap.com  or TheJungleMap.com.  See the difference?

Who cares?

Well, if you did a search in Google, you would notice that they had about 5 pages from www.TheJungleMap.com and about 100 pages from TheJungleMap.com.  Strange, right?  Now, there is a setting in the Google Webmaster Tools that allows you to let Google know which you prefer.  That helps.

But more importantly, if users can see your site either way, they may link to either one.

But how does all this affect me?

Here’s where the danger lies.  If you have links to both the www version of your site and the non-www version, Google may count those as separate pages.  WHAT?!?  Google actually doesn’t realize that the www and non-www pages are the same page and consolidate the link equity (PageRank)?

Yes, it’s true.  Seems stupid to me too, but it is true (at least for now).

Do I have a “www and non-www issue”?

Check by typing this into Google (or the other search engines):




(Obviously, you need to change the “YourSite.com” to be your domain name.)

See how many of your pages are listed in the index.  Is it a different number?  Then you might as well fix it.

How do I fix this (normally)?

The best way is typically to edit your .htaccess file.  I followed these instructions…

Step 1: Create .htaccess file

If it doesn’t already exist, create a file on your server’s document root (the top most web accessible directory) and name it .htaccess.

Note to windows users: Windows makes it difficult to save files begging with a period, to bypass this issue name the .htaccess file something else while editing locally, and rename on the server.

Step 2: Add rewrite code to .htaccess file

Add the following lines to the the .htaccess file:

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

Replace www\.yoursite\.com with your own website, remembering to escape any periods with a backslash. Then, also replace http://www.yoursite.com/ with your own site’s address. That’s it.

What if I use WordPress?

If you have a WordPress blog and want to fix the www and non-www issue, it’s a little different.

Simply install the plugin offered at http://txfx.net/code/wordpress/enforce-www-preference/.

That should do it!