• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Caconical URL Redirecting..


Senior Member
Hi guys,

Ive just read an article about caconical URLs and how its a good idea to redirect one url to another url for SEO/indexing purposes - which made perfect sense.

Its the first ive heard about them, and i wondered do you guys know:

1) which url (the http://www., or the http://) to redirect to which?
2) How i do the redirecting part?

Thanks!! :D


Senior Member
My guess would be to redirect to a www. address ...

Since we're on topic... why do some sites not work without www while some (well, most) of them do (edit: without directing to one or the other)?


Active Member
Essentially it's to tell the SE's that 'this' content is the same as 'that' content to avoid duplicate content penalties, a good example for usage is a product page appearing in two categories within an e-commerce site for example, another example would be licensed content, if you've given someone permission to use your content on another URL adding this tag will tell the SE's that it's the same content as 'this' URL.

This post at SEOMoz will explain a lot better than I can!
SEOmoz | Canonical URL Tag - The Most Important Advancement in SEO Practices Since Sitemaps

tbwcf said:
If you don't do this effectively you have two websites up which will hurt rankings.
& yep Andy's spot on, having both the WWW and non-WWW load the site will mean that Google and other search bots will think the 2 sites are different sites and any link equity will be shared between the two, I think there's even risk of minor duplicate content penalties too.


Senior Member
Onartis said:
My guess would be to redirect to a www. address ...

Since we're on topic... why do some sites not work without www while some (well, most) of them do (edit: without directing to one or the other)?
If the host is missing the * A record which handles wildcards or the www record then one will work and the other won't.

Just sloppy DNS setups to be honest.


Senior Member
DAMN I just wrote such a huge reply and accidentally refreshed page.. 0_0

Okay attempt 2..Thanks for all the posts in reply people, all were helpful, I was interested to know answer to Onartis' Q as well :)

Okay, so from what Ive gathered:

1) It doesnt matter which you redirect from/to?

2) If I wanted to - for example - get the non-www url to redirect to www, I would simply copy and paste:

RewriteEngine OnRewriteCond %{HTTP_HOST} !^your-site.com$ [NC]RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]
into .htaccess file, and upload to root directory of site? This doesnt look like a snippet for a usual 301 redirect to me..Do I need to do anything else to it? (My sites contents are contained within /public_html/ - this is the root?)

2) One of my sites is a Wordpress blog. I found this article: WordPress 2.3: Canonical URLs Mark on WordPress

How do I make sure my blog isnt using 'non-canonical' urls? And stop people from seeing them in their address bar?

Thanks for continued help :)

PS: This article might be good reading for people a little more experienced.. I wonder if it is used as much as the above method yet..:)


Active Member
Personally change it from this ~
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

To this ~
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301, L]

But what this says is if it is not your-site.com redirect it to using a 301 redirect, which is a permanent, redirect to example.com/.

Yes upload it to your root (public_html) directory.

To make sure it is compatible with wordpress from what I gathered just reading that post, set your redirect up to match where you have designated your wordpress blog.

So if you tell wordpress to be under the www. version make sure the 301 redirect is set up to match the www. url.

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

Does that make sense?

Right now for that tag, now that tag IMO should only be used on similar pages, articles under different categories that sort of thing. You would run into issues if you tried to set 2 up as far as I know probably not best practise. That would also be required on every page which increases code bloat, lowers page performance, and TBH probably wouldn't be the best for incoming links.

Setting up a 301 helps, eventually, to consolidate all your equity which is the best thing about doing it.

Set the 301 up in the .htaccess and then if you have similar pages under different url's then use the link tag with the canonical attribute.

That way you are using both as they should be used IMO.


Senior Member
Thanks jaz for clearing that up :) My htaccess file currently looks like this:

<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]#----- START DAP -----RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} (.*)/wp-content/uploads/(.*) RewriteRule (.*) /dap/client/website/dapclient.php?dapref=%{REQUEST_URI}&plug=wp&%{QUERY_STRING}  [L] #----- END DAP -----</IfModule>Options -Indexes
so do i just paste the snippet you wrote above into that same page before or after the section already there? This is for protection of some mp3s - was there already. with the rel=canonical tag, there is a wordpress plugin that can do that for me (WordPress › SEO No Duplicate WordPress Plugins), and i think i already have one that will do it - all-in-one seo pack, but im not sure whether the article i pasted in above actually advises to use it.. not quite sure what you meant by why id run into issues, is it a good idea to use this plugin?


Active Member
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^your-site.com [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [R=301, L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Should do it for you, obviously change it to your site name. :)
That will redirect it to the non www. version.

If you get an error take it down and delete those 2 lines and let me know what error you get, you shouldn't.

The reason I said you may run into issues is because what happens if you set the www. via the link tag and then need to set up another 1?
Not sure what would happen if you had 2 up TBH, but this will get round it if that came up anyway, and should be the way you should sort out www. and non www. canonical issues IMO.


Senior Member
thanks for that :) out of interest - are you more of a designer or programmer? you seem to know every language going :D

i still dont quite understand what you mean by setting up two rel="canonical" tags - i think this tag goes in the head of every page, are you saying I shouldnt do it along with the redirect, and do one or the other?


Active Member
I'm a programmer who's learning design.
I have an OCD when it comes to learning something new, I tend to get a tad obsessed so.
Ask me about health if you think I'm a geek about coding. :)

Anyhoo for example if you had this set up ~
<link rel="canonical" href="http://yoursite.com/" />

And then needed to write 1 for a particular article, which IMO it should be used for, you would then need 2 so ~
<link rel="canonical" href="http://yoursite.com/" />
<link rel="canonical" href="http://yoursite.com/dir1/article" />

So set up the www. via the htaccess/server files and then if you have a copy of a file link to the correct file via the link tag with the canonical attribute to tell the search engines that the article is a copy.

Does that make more sense Emma? :)


Active Member
o dévers je (O can't i)?

Actually no, no I can't I just looked that up but I soooo want to though, that and Spanish, maybe next year hay. ;)


Senior Member
Du weißt vielleicht gar nicht was 'Dieu' bezeichnet...

Oh yeah! I speak German too :up:
(edit: and dutch... I'm tetralingual or something)