Page 1 of 2

SEO: Canonicalization

Posted: Tue Mar 25, 2008 4:58 pm
by alledia
1. INTRODUCTION

Making sure that Google doesn't treat http://www.mydomain.com or mydomain.com as different domains

2. SCOPE

Canonicalization is big word I can rarely spell but the idea is pretty simple. If the site is based on http://www.mydomain.com or mydomain.com, all the pages will show the same way. Currently we need to add extra lines of code in .htaccess to do this. Wordpress does it automatically.

Re: SEO: Canonicalization

Posted: Tue Mar 25, 2008 8:50 pm
by AmyStephen
No. I do not agree that we would automatically decide people can't have www in their domain name.

Obviously, I think it's a good idea, which is why I added it as a GHOP task and worked with the student to provide documentation on how to do so.

But, not everyone wants this - further, it must be defined in Google Webmaster services, anyway, so it couldn't be taken care of in core.

Wonder about the Wordpress claim. Must be an add-on. Certainly, core WordPress doesn't do this.

Amy :)

Re: SEO: Canonicalization

Posted: Tue Mar 25, 2008 8:53 pm
by newart
AmyStephen wrote: But, not everyone wants this - further, it must be defined in Google Webmaster services, anyway, so it couldn't be taken care of in core.
exactly my idea, sorry I agree with Amy. I don't see a very need for that!

Re: SEO: Canonicalization

Posted: Tue Mar 25, 2008 8:55 pm
by AmyStephen
Who in the world would be sorry that they agree with Amy? :D

Re: SEO: Canonicalization

Posted: Tue Mar 25, 2008 9:00 pm
by alledia
Misunderstanding here ... Wordpress helps you if you want www OR non-www

They simply help you maintain your choice across the whole site.

Re: SEO: Canonicalization

Posted: Wed Mar 26, 2008 3:09 pm
by AmyStephen
If it could be handled in the router and there was a new Global configuration option that could be activated only if you used an .htaccess file, then I agree, this would be a nice feature to have. It can make a significant difference on your Google Page Rank. (I wonder, though, if Google will ever fix this.)

Thanks for helping me understand this better.

Re: SEO: Canonicalization

Posted: Fri Apr 11, 2008 3:59 am
by pasamio
Can you give a more formal example of how things should be changed, for example, with http://www.joomla.org with examples of what is happening now and what should happen.

Re: SEO: Canonicalization

Posted: Fri Apr 11, 2008 12:14 pm
by alledia
From Matt Cutts at Google:
http://www.mattcutts.com/blog/canonicalization-update/
Some people ask “Why don’t you just assume http://www.example.com and example.com are the same?” The answer is that they don’t have to be, and for some websites they are different. For example, http://phpicalendar.net/ is a different page than http://www.phpicalendar.net/. This happens more often than you might think; FindWhat has different www vs. non-www pages, for example.
So http://www.joomla.org and joomla.org can be indexed and ranked as if they were separate sites. Not definitely going to happen, but its possible. Currently I see the same content if I visit http://www.joomla.org and http://joomla.org.

In 1.0 $mosConfig_live_site would be the logical choice to set the choice of www or non-www. In Joomla 1.5 I'm not so sure.

Wordpress info:
http://wordpress.org/support/topic/156533
http://perishablepress.com/press/2008/0 ... wordpress/

Re: SEO: Canonicalization

Posted: Fri Apr 11, 2008 2:13 pm
by pasamio
1.5.1 has a live_site variable in it if you need to use it, though upgrade to 1.5.2 if possible.

I will check out what Wordpress has got going soon to see how they handle things.

Re: SEO: Canonicalization

Posted: Fri Apr 25, 2008 12:00 pm
by pasamio
Still haven't gotten around to checking out wordpress, but give what I've attached a go. Basically you install it, feed it the correct hostname and when the hostname doesn't match (as per $_SERVER['HTTP_HOST']) then it resets the location, sends a 301 (Moved Permanently) and kills the app. Let me know if this is similar to what you're chasing and resolves the issue for you.

edit: updated XML installer and swapped a variable
edit 2: updated to fix SSL detection code

Re: SEO: Canonicalization

Posted: Fri Apr 25, 2008 3:17 pm
by alledia
Thanks Sam

Tested this on 1.5.3 but couldn't get any traction.

Could you post some quick instructions for setup?

Re: SEO: Canonicalization

Posted: Sat Apr 26, 2008 1:36 am
by pasamio
All you need to do is feed the correct value of HTTP_HOST into the plugin's params and it'll update any URL with a 301 to point to the correct HTTP_HOST. And publish it as well. To test just go to your site at one of its alternate addresses, so in my case I used sammoffatt.com.au and hit it on http://www.sammoffatt.com.au instead.

Re: SEO: Canonicalization

Posted: Sat Apr 26, 2008 3:01 pm
by pasamio
I've updated the original to fix an issue with SSL detection now that I've tested some stuff on an SSL enabled server. I've replaced the original attachment with the new one (only a slight change).

Re: SEO: Canonicalization

Posted: Sun Jul 06, 2008 6:09 am
by Hokuszpok
In my case the plugin didnt work well, it went into an endless redirecting loop.

My site is on a free host, the free name for the site is http://XXX.extra.hu. Now I got a real domain name for the site, which is http://XXX.hu, plus I got the www version with it too, which is http://www.XXX.hu.

I wanted to use the http://www.XXX.hu name variant everywhere. The problem with your plugin is that the HTTP_HOST in my case points to either XXX.extra.hu or XXX.hu depending on the call, but never contains the http://www.XXX.hu - which I wanted to use! So if I set the preferred hostname to http://www.XXX.hu in admin with your plugin, I got into an endless loop, because the plugin will NEVER see the www variant, so always tries to redirect :(

Your code in my setup successfully hides the original free name XXX.extra.hu, but can't tell http://www.XXX.hu and XXX.hu apart.

I replaced HTTP_HOST with SERVER_NAME which returns not the hostname, but the virtual host name. It seems to work in my (somewhat weird) setup!

Thanks for your plugin, I was looking for this one for some time!
(btw XXX = 'enekelazorszag', its a long hungarian name of a project)

Re: SEO: Canonicalization

Posted: Sun Jul 06, 2008 6:44 am
by pasamio
That is rather strange, I just looked on my local machine and SERVER_NAME returns 127.0.0.1 whilst HTTP_HOST returns 'localhost'. My VHOST server returns the correct name (sammoffatt.com.au), that said, so does HTTP_HOST. I'll look into putting an option in to change it.

Re: SEO: Canonicalization

Posted: Sun Jul 06, 2008 7:00 am
by Hokuszpok
My host is free one with some weird setup. They disable .htaccess, and lot of php functions - even realpath in php (I had to modify some Joomla files because of that one). So my case may be rather unique.

Anyway the plugin works nicely after I replaced HTTP_HOST with SERVER_NAME.

Re: SEO: Canonicalization

Posted: Sun Jul 06, 2008 1:41 pm
by alledia
Thanks Sam for the plugin.

I wonder if there's a way to include it as a core function.

After all, researching, downloading, installing and configuring is a longer process than the original solution ... just adding two lines to the .htaccess file.

Re: SEO: Canonicalization

Posted: Mon Jul 07, 2008 5:53 am
by pasamio
I've updated the extension to handle both SERVER_NAME as well so if either it or HTTP_HOST matches it will not redirect. I've also added an option to disable it in the backend (enabled by default) and a simple check function with an iframe to validate settings. If you end up with a browser error then something isn't right otherwise it should come up with success.

re: including it into 1.6 (1.5 is out of the question), I'll have a chat with the powers that be about including it and see what they think. It needs a bit of a clean up before it gets into core but I don't see too many issues. If it does get included chances are it'll be almost identical code so if you can test this now and see how it works then that'd be a good start. Finally whilst it may be harder, on platforms that don't have .htaccess files this solution still works as well which is good.

Download here:
http://joomlacode.org/gf/project/pasami ... ge_id=3609

Re: SEO: Canonicalization

Posted: Mon Jul 07, 2008 1:41 pm
by tim1980
thanks so much for creating this plugin
im using it on www.PanicIndustry.com

I also have .net .org .tv and it works to redirect them all to .com excellent

Re: SEO: Canonicalization

Posted: Tue May 12, 2009 12:31 pm
by pasamio
Hi Tim,

Great to hear that it works for you, would you also be interested in posting a review or ranking on the JED?

http://extensions.joomla.org/extensions ... 55/details

Cheers,

Sam

Re: SEO: Canonicalization

Posted: Tue Jun 02, 2009 5:32 pm
by kolkataseo
this is one simple yet power tweak for SEO which alot of people miss out

Re: SEO: Canonicalization

Posted: Sun Jun 28, 2009 9:03 pm
by Vespre
The canonical tag will (is claimed to, at least) solve this issue now. A 301 redirect from either www to without or the other way around is a safer bet though.

Re: SEO: Canonicalization

Posted: Mon Jun 29, 2009 10:15 pm
by VitalBodies
Awesome, helpful, supportive. This plug-in helps!

Re: SEO: Canonicalization

Posted: Wed Jul 22, 2009 10:44 pm
by RickGlaser
Alledia, thanks for pointing this out. Many people overlook this important factor, and actually can get punished for duplicate content. The pronunciation well that would be pronounced KAH-nahn-nihk-uhl-ih-ZAY-shun for anyone wondering.

:)

Re: SEO: Canonicalization

Posted: Mon Oct 19, 2009 5:04 am
by tim1980
Thanks again for this, years later I had to find this plugin again

im still confused abou tit though, what is a .htaccess way of doing this?

Re: SEO: Canonicalization

Posted: Mon Oct 19, 2009 5:09 am
by tim1980
oh no it does not work anymore with 1.5.14

The page isn't redirecting properly




Firefox has detected that the server is redirecting the request for this address in a way that will never complete.








* This problem can sometimes be caused by disabling or refusing to accept
cookies.

Re: SEO: Canonicalization

Posted: Mon Oct 19, 2009 5:32 am
by pasamio
It works perfectly fine on my 1.5.14 site, I'd look to something else to work out what is going on. Redirect loops occur when you redirect to one place and then back to where you redirected from and around and around until the browser gets dizzy and sits down. There is potentially a configuration alteration somewhere on your side that could have caused it but my 1.5.14 sites are working perfectly fine.

Re: SEO: Canonicalization

Posted: Wed Nov 25, 2009 6:31 pm
by dubjohnston
Hi Sam,

Thanks for the work you put in.. I used to use a different Canonicalization plugin but thought id give yours a go as the old one i still had to touch the htaccess file.. I downloaded your plugin and when i type in the address i want it pointed to 'www.majorchord.net' it tells me that 'Failure! Domains dont match'.

I clicked rewrite (brand new site so didn't matter if i stuffed up) but it couldn't find a connection.

I am using 1.5.15 and haven't renamed htaccess.txt to .htaccess yet.. do i need to?


Search Engine Friendly URLs: Yes
Use Apache mod_rewrite: No
Add suffix to URLs: No

your help would be much appreciated..

cheers

dub

Re: SEO: Canonicalization

Posted: Thu Nov 26, 2009 12:28 am
by pasamio
Going from memory, when you're doing the test, you've hit apply first (without enabling the plugin; think that should work properly)? Will have to have a look over the code which is always time consuming. Lots of time!

Re: SEO: Canonicalization

Posted: Mon Dec 07, 2009 11:08 am
by dubjohnston
Hi Sam,

Thanks for the fast reply.. I tried what you suggested.. still showing without the www..

since last time I have amended the site settings as below and renamed the htaccess file

Search Engine Friendly URLs: Yes
Use Apache mod_rewrite: Yes
Add suffix to URLs: No

Can i double check i am doing it all right.. i cold be missing something simple.. I want all domains to have www.

Correct Host: www.gengreen.com.au
Backend enabled: yes

when i click on a menu item for example.. still goes to non-www site

thanks again for your help mate..

cheers

dub