|
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…
RewriteEngine on
RewriteCond %{HTTP_HOST} ^chris-hooley\.com
RewriteRule ^(.*)$ http://www.chris-hooley.com/$1 [R=permanent,L]
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!
You can leave a response, or trackback from your own site.
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. |
Pete Wailes Says:
May 21st, 2007 at 2:20 am
Man, everything you ever post just makes me crack up. Legend.
tacimala Says:
May 21st, 2007 at 9:03 am
This only works for Apache based servers, just wanted to note that. If only everything was Apache!
RickBreslin Says:
May 23rd, 2007 at 4:06 pm
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
RickBreslin Says:
May 23rd, 2007 at 4:07 pm
[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
Jason Hendricks Says:
May 25th, 2007 at 9:14 pm
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/
Adam Yax Says:
May 30th, 2007 at 3:41 am
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.
Jim Spencer Says:
May 30th, 2007 at 10:40 pm
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]
Google PageRank & Play-Doh Says:
August 17th, 2007 at 9:56 am
[...] 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 [...]
Mark Kirby - Brighton » Blog Archive » links for 2007-08-22 Says:
August 22nd, 2007 at 3:19 pm
[...] Canonicalize with .htaccess URL Canonicalization is making sure that each page is accessed in ONLY one uniform way. (tags: seo blogging) [...]
By Design: Building Trust, Security, Links | Logo Design Works Says:
September 5th, 2007 at 3:49 pm
[...] 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 [...]
JBS Partners » Blog Archive » Canonicalization can more than double the link love Says:
September 9th, 2007 at 6:36 pm
[...] Hard core documentation from Apache Google’s Matt Cutts offers his advice about canonicalization Chris Hooley explains canonicalization [...]
Mendy Ouzillou Says:
September 25th, 2007 at 11:05 pm
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
Canonicalize your URL's | Hey Peter Man Says:
October 8th, 2007 at 2:31 pm
[...] Chris Hooley [...]
Maria P. Says:
December 2nd, 2007 at 3:36 pm
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]
Mirna Says:
May 22nd, 2008 at 5:02 pm
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!
Chris Hooley Says:
May 22nd, 2008 at 5:44 pm
If they allow server side scripting, it can also be done with PHP, ASP, or whatever language(s) they allow.
web design studio Says:
March 7th, 2009 at 9:50 am
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
Chris Hooley Says:
May 7th, 2009 at 6:25 pm
A simple 301 redirect will work fine for that.