Blog marketing and the canonical domain issue

As some of you may already know, search engines treat “www” (e.g. http://www.blogopreneur.com) and “non-www” (e.g. http://blogopreneur.com) domains as totally different domains, until Google allowed you to set a preferred domain to use in your the Google Webmaster Center.

Preferred Domain Setting on Google Webmaster Center

So it is important to resolve this canonical domain issue if you want to market your blog, or website - so you don’t risk duplicate content (though I believe search engines today should be smart enough to see this potential problem) and so that your marketing efforts will be focused on one URL.

In most of the domains that I administer, I usually redirect all my “non-www” traffic to my “www” domain. But today I was researching how to do the opposite, since “www” is a subdomain afterall, and the “non-www” one is the real domain. I searched and I found this good resource on Webmaster World.

# Redirect if NOT www.example.com (exactly) to www.example.com
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# Redirect if example.com (case-insensitive) to www.example.com
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# Redirect if NOT example.com (exactly) to example.com
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]

# Redirect if www.example.com (case-insensitive) to example.com
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]

Now we can do whatever we want! In particular, if you want to redirect all other subdomains to your root domain (not only your www one), you can use the third paragraph of code. Neat!

Tags: ,

If you enjoyed this post, Sign up for the free Blog Marketing eCourse.

8 Responses to “Blog marketing and the canonical domain issue”

  1. Mike Markie Says:

    Visit Mike Markie

    If you want to cheat and install a plugin you can use No WWW.

  2. Kian Ann Says:

    Visit Kian Ann

    hey Mike! Yeah! WordPress plugins are wondrous aren’t they! :)

  3. Shi Hengcheong Says:

    Visit Shi Hengcheong

    Hi Kian Ann,
    I did not test out the mod-rewrite script you stated above. The “third paragraph” will probably work fine if Wordpress were installed in the root directory. However, I was having problem with the re-direction for Wordpress installed in the sub-folder.

    http: //shihengcheong.com/blog (without trailing slash) was redirect to http: //www.shihengcheong.com/blog/

    I’ve solved this problem and the solution is post here:

    Fixing Canonical URLs Problem with Wordpress URL Rewrite

    You see, the right convention in Unix/Linux directory structure is to use a trailing slash for a folder. When there is no trailing slash, that should be a file.

    When you selected the use of SEO friendly URL in Wordpress, the mod-rewrite changed the server default.

  4. Mike Markie Says:

    Visit Mike Markie

    I thought I should update you on my situation at the moment I’ve noticed in my admin panel for wordpress that you need to use www . to upload pictures so when I was telling it not to use www it wouldn’t upload my pictures so i recommend using www .

  5. Harro! Says:

    Visit Harro!

    Hi KA, I think that hosting and diskspace is so cheap now that creating multiple installations is not an issue vs. people trying to figure out rewrite rules.

    Also having multiple domains pointing to the same content is going to be something that google doesn’t appreciate right? :)

  6. Kian Ann Says:

    Visit Kian Ann

    Hey Mike - I didn’t notice that! So you mean for WordPress installations, you need to use the www version all the time?

  7. Kian Ann Says:

    Visit Kian Ann

    Hey Harro,

    Well, you could install multiple copies of anything and everything - but that will only mean that when you update, you will need to update all copies… and yes, duplicate content is a big no no when Google is concerned!

  8. Mike Markie Says:

    Visit Mike Markie

    Yeah, when i forced it not to use www I found i was getting no spam because people couldn’t comment as you need to use http://www.
    I couldn’t upload pictures I found a lot of problems when i was using it :s .


Comments

Subscribe without commenting