With My Mind on My Money and My Money on My Mind

 

URL Canonicalization is making sure that each page is accessed in ONLY one uniform way.

Now, if you have a website, it probably has a home page. (If it doesn’t that’s just weird but I digress…) That home page can probably be accessed via the following URLs:

http://domain.com
http://www.domain.com
http://domain.com/index.php
http://www.domain.com/index.php
https://domain.com
https://www.domain.com
https://domain.com/index.php
https://www.domain.com/index.php

That’s 8 DIFFERENT URLs for ONE PAGE.

Now imagine if you had 80 links to your site, but they are split equally over those 8 variations. That essentially means you have 10 links to 8 pages according to Google, AND a duplicate content problem to boot.

So what’s a web developer to do? People will just link to whatever they want right?

Right.  BUT you can FORCE canonicalization, and it’s REALLY simple when you have an apache server (running PHP) - so all you blog junkies, listen up.

At the public root on your website, there is a file called .htaccess. This file controls the configuration of your server on the domain level. There are all kinds of tricks you can do with this file, but I am only gonna show you ONE trick that you should use EVERY TIME you set up a new website.

Check it out and do this every time

  • Open up your .htaccess file.
  • Add the following code (to the top or bottom, it doesn’t really matter)

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^chris-hooley\.com
    RewriteRule ^(.*)$ http://www.chris-hooley.com/$1 [R=permanent,L]

  • Replace chris-hooley with the name of your site, and the TLD (the .com) with the TLD of your site if different (for example, .net, .org, etc)
  • Now open up a browser and try typing in your address without the WWW.

You can’t. It’s that easy. All link popularity now hits ONE SINGLE version of your domain name.

This trick can be expanded upon to eliminate secure calls to your site and also to eliminate direct page access, but the main thing is that your domain is clean and canonicalized.

So… happy blogging people, and from now on part of your SEO site launch routine should involved a 45 second update to your .htaccess file.

w0rd!


Share and Enjoy: save to del.icio.us submit to digg furl this submit to ma.gnolia submit to RawSugar Add the BlinkList NetVous NewsVine Yahoo! MyWeb


You can leave a response, or trackback from your own site.

18 Responses to “Canonicalize Yo Shizzle with .htaccess EVERY TIME”

  1. See my profile on MyBlogLog.com!
    Pete Wailes Says:

    Man, everything you ever post just makes me crack up. Legend.

  2. See my profile on MyBlogLog.com!
    tacimala Says:

    This only works for Apache based servers, just wanted to note that. If only everything was Apache!

  3. See my profile on MyBlogLog.com!
    RickBreslin Says:

    Great post, Chris!

    For everybody hosted on Windows boxes: there’s a very powerful (and free) server component called ISAPI_Rewrite that will help you with this. It acts exaclty like an .htaccess file (stored in the root of the domain). The component will also let you convert ugly URLs with huge query strings into neat “search engine friendly” web addresses.

    And here’s a blog post that shows you how to perform exactly what Chris was talking about (but using the ISAPI_Rewrite httpd.ini file instead of an .htaccess file).

    Still hosted on Windows and dealing with it,

    Rick

  4. See my profile on MyBlogLog.com!
    RickBreslin Says:

    [resubmitting with correct external blog link]

    Great post, Chris!

    For everybody hosted on Windows boxes: there’s a very powerful (and free) server component called ISAPI_Rewrite that will help you with this. It acts exaclty like an .htaccess file (stored in the root of the domain). The component will also let you convert ugly URLs with huge query strings into neat “search engine friendly” web addresses.

    And here’s a blog post that shows you how to perform exactly what Chris was talking about (but using the ISAPI_Rewrite httpd.ini file instead of an .htaccess file).

    Still hosted on Windows and dealing with it,

    Rick

  5. See my profile on MyBlogLog.com!
    Jason Hendricks Says:

    Nice. And if you don’t feel comfortable editing .htaccess files, there’s a plugin that will enforce your preferred URL (wordpress blogs only).

    http://txfx.net/code/wordpress/enforce-www-preference/

  6. See my profile on MyBlogLog.com!
    Adam Yax Says:

    Windows IIS servers have this ablity.
    Setup two seperate “sites” both with host headers (one for http://www.domain.com as your main with only that), the other site put multiple host headers ( domain.com wwwmistype.domain.com, include https for domain.com here as well), but in that second “site” use a permanement redirect to your ‘official’ site that has only the http://www.domain.com in it’s host header. Now you have redirection of alternate domains but be sure to check permanenet. As for the “index.html (and variations)” You can change the code in your site so all home links point to “/” instead of index.html, so internal linking can focus on one place. But to really hit the mark you can setup a new “default” file, copy your original into it (name it whatever.html), set this as your first default document, and then inside IIS right click the originaly file (likely default.html or index.htm/asp) and do a redirect there as well, pointing it to “/” which is ultimately defaulted now to “whatever.html”. A final touch might be to slap an IIS redirect ISAPI filter into the mix, get rid of some of those nasty querystring ?=s. Anyway, these have helped us on the windows side of things.

  7. See my profile on MyBlogLog.com!
    Jim Spencer Says:

    If you work with different sites, this might be a good way to go!

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

  8. See my profile on MyBlogLog.com!
    Google PageRank & Play-Doh Says:

    [...] version over the other. For detailed instructions on how to do this, read Chris Hooley’s article, Canonicalize with .htacces. Your goal is to make one version redirect to the [...]

  9. See my profile on MyBlogLog.com!
    Mark Kirby - Brighton » Blog Archive » links for 2007-08-22 Says:

    [...] Canonicalize with .htaccess URL Canonicalization is making sure that each page is accessed in ONLY one uniform way. (tags: seo blogging) [...]

  10. See my profile on MyBlogLog.com!
    By Design: Building Trust, Security, Links | Logo Design Works Says:

    [...] combination of the above results in eight unique URLs. Chris Hooley offers an .htaccess tutorial to canonicalize your URLs. That simply means redirecting them to a single consistent URL. Note that this is a more advanced [...]

  11. See my profile on MyBlogLog.com!
    JBS Partners » Blog Archive » Canonicalization can more than double the link love Says:

    [...] Hard core documentation from Apache Google’s Matt Cutts offers his advice about canonicalization Chris Hooley explains canonicalization [...]

  12. See my profile on MyBlogLog.com!
    Mendy Ouzillou Says:

    I’ve just tried the .htaccess suggestion for my website http://www.trezora.com and while it delivers on the http://trezora.com, it doesn’t work on http://www.trezora.com/index.html

    Any suggestions?

    Mendy

  13. See my profile on MyBlogLog.com!
    Canonicalize your URL's | Hey Peter Man Says:

    [...] Chris Hooley [...]

  14. See my profile on MyBlogLog.com!
    Maria P. Says:

    What about on a non PHP page? Just an html page.

    I’ve got domain.com to go to http://www.domain.com and

    domain.com/index.html to go to http://www.domain.com/index.html

    How do I point the index.html to the root?

    Using the redirect with the index.html versions in place didn’t do anything.

    Something like this didn’t work either…. I know I’m missing just some obvious step…

    RewriteEngine On
    RewriteCond %{THE_REQUEST} /index\.html [NC]
    RewriteRule ^(.*/)?index\.html$ /$1 [R=301,L]

  15. See my profile on MyBlogLog.com!
    Mirna Says:

    Everyone is telling me I need to do this for my website, but my site is being hosted by Yahoo! and they do not allow .htaccess files…is there another way I can do this?

    Thanks!

  16. See my profile on MyBlogLog.com!
    Chris Hooley Says:

    If they allow server side scripting, it can also be done with PHP, ASP, or whatever language(s) they allow.

  17. See my profile on MyBlogLog.com!
    web design studio Says:

    Hello, I have a problem. Hope you will help.
    For example, let say I have na url like this http://www.this.com/this.php. Now I would like to rename this url to http://www.this.com/that.php. Is there any way I could save my Seo on my link even if I rename it. Is there somekind of redirect that Google won’t ban?
    Best reagrds

  18. See my profile on MyBlogLog.com!
    Chris Hooley Says:

    A simple 301 redirect will work fine for that.

Leave a Reply




Chris Hooley’s -ThinkBait- is powered by WordPress
This is copyrighted stuff. You can't steal it unless you are a jerk. If you like it, send traffic to it.