Canonical URLs
May 18, 2007 Posted by Tyler CruzWhile I was in my dashboard yesterday, I noticed a linkback with an excerpt of “I noticed on tylercruz’s blog, he’s made a major mistake, and one that has cost him dearly in terms of PR…”. This obviously peaked my interest, and so off I went to check it out.
Now, as some of you may already know, I’m a perfectionist and I like to really research things before I make decisions. I indeed did know of the split URLs in the past, but never did anything about it because I knew I wouldn’t unless I spent the time to research it properly.
Just kidding, you can stop writing the hate comments 😉
My research quickly supported the theory that it was better to have one URL instead of two, which is what I had always believed, but I’ve also always been very skeptical about SEO. This is mainly because I believe that SEO is an inexact science, mostly theories, since algorithms such as Google’s PageRank and search engine are a close guarded secret. That being said, I’m not arguing that SEO is very important. It’s just that I’m going to do a bit of research before jumping aboard the band wagon and start copying what all the kids are doing these days.I found that John Chow had discussed this same thing a little while back, as well as Matt Cutts, a Google employee, however Matt’s was much more in-depth and technical.
I then asked my long-time programmer Zeeshan friend his thoughts, and he gave me his usual alien language responses: “Google is just obeying RFCs… www.example.com and example.com are two seperate fully qualified domain names (FQDNs)” … or in other words “Yes, it’s better to have one URL”.
I then decided to visit popular blogs and websites, and found that most large sites redirect from http://example.com as well. However, I did notice that some sites such as YouTube, MySpace, and Amazon did not, to which Zeeshan replied “They don’t to lower HTTP response times, but it’s a common thing if you want to distribute your PR to one hostname.” Which is what I had assumed, and agree with. Just look at Google’s source code. But that’s another post for another day…
After I was satisfied with my research which concluded that it was indeed preferable (Google itself states they prefer this!) to have one URL, I started to change all of my sites to reflect this.
The change is pretty basic. You want to 301 redirect http://site.com to http://www.site.com. A 301 redirect is just a fancy technical code for permenant; rather than temporary. Most sites seem to recommend creating or modifying an .htaccess file to do this, but that is actually very poor advice. It would be much preferable to make such a change on the actual server level. With Apache on linux servers, this is a simple edit to the httpd.conf file. Using an .htaccess file will slow down processing times and makes no sense when this can easily be done the other way.
So, I went ahead and modified over a dozen of my sites to reflect the changes. To do this, I took out ServerAlias tylercruz.com from my VirtualHost block for www.TylerCruz.com and created a new VirtualHost block below it for just TylerCruz.com:
# TylerCruz.com
<VirtualHost 69.93.63.130>
# This block 301/permenant redirects from non-www to www URL for canonical URLs
ServerName tylercruz.com
Redirect permanent / https://www.tylercruz.com/
</VirtualHost>
And as you can see, https://tylercruz.com now automatically redirects to https://www.tylercruz.com. Not only is this ‘cleaner’, but it should definitely help in terms of SEO and pagerank in the future. Maybe I’ll be a PR6 by the next update in several months now that I’ve fixed this.
This will also help fix when people link to my blog from the first URL as well, as many people do (which is a pet peeve of mine), since users will be redirected anyway. And to reiterate, I’ve made this change on all of my sites, so it will be very interesting to see the SEO benefits of this in the future.
Anyhow, that’s the end of this little blog post. However, for those still interested, before I go I’d like to talk about canonical URLs and vBulletin.
First off, making the above changes will help my forums in an additional way. Apparantly vBulletin uses separate cookies depending on if the URL is www or non-www. For example, previously, when I went to http://www.movieforums.org I’d be logged in. However, if I typed in http://movieforums.org instead, I wouldn’t be, becuase my cookie was set to the former, so I’d have to log in again. Now I won’t have this issue anymore, which means that none of my thousands of members will either 🙂
Anyhow, I have a question for you smart mod_rewrite guru’s out there. I spent a good 3-4 hours today trying to also mod_rewrite vBulletin into a canonical URL as well. We all know that vBulletin has /index.php and by default links to it throughout their software. I know that I could change the phrases and the links throughout the templates, and I also know there are a couple of other MacGyver ways to do this, but I want to have just www.movieforums.org instead of www.movieforums.org/index.php through mod_rewrite via httpd.conf only.
The closest I had got was using: “Redirect permanent /index.php http://www.movieforums.org”, which would in theory work fine. However, since vBulletin uses index.php by default, this creates an endless loop which ultimiately times out.
So, I believe the answer is to use conditional RewriteCond and RewriteRule’s. However, despite my intense labourous searches through Google, vBulletin’s support forum, and asking on IRC, I came up empty-handed. Does anyone out there know the answer? If so, please provide exact syntax of what I need since I’m a moron 😉
Thanks guys.
(If you enjoyed this article or found it helpful, please take the 10-seconds it takes to Digg it below.)
I am far from proficient on this but when I did the exactly same thing for my websites I had to insert/modify the code within .htaccess file.
So in other words you lost me somewhere around that Virtual Host bit (mind you I dont run and vBulleting or any other forum sites if that makes any difference)
Cheers
Dan
Virtual hosts configurations are set within the httpd.conf file. But this file is not normally accessible for people who use a “shared hosting” service.
I prefer redirecting to the NON www version of my domains. Why? Because the DNS then takes up less characters for links and in the address bar!
hmmm…
I am working on a php web site and using mod rewrite i have the files ending with .htm.
i.e. mysite.com/test.htm but the same url can be accessed from mysite.com/test.php
should i be concerned about this?
Well you can easily make all those files redirect to .htm using the same method above. However, if you don’t link anywhere to the .php files, you should be fine since the SE’s won’t know about them and others won’t link back to them.
It’s really only what’s visible to the SE’s, as far as I can tell.
[…] read more | digg story […]
I had the same problem, except the first time I tried the 301 redirect I screwed it up. Lots of head scratching and a few hours later and I got it fixed though.
[…] my-domain.com to http://www.mydomain.com Tyler posted a nice little blurb about this here and I’m thinking it’s not a bad idea to go ahead and do… anyone have their own thoughts on this? […]
“I’d have a PR of 9 (5+4=9)!” lol!
Talk about bait and switch … I was all set to get that PR 9, it was going to be a great weekend for me LoL. It’s be interesting to see just how many people leap off at that point and go out trying to add multiple PR’s together *smile*.
One thing worth looking at that may make this simpler for some folks is cPanel. Mnay of us have shared, virtual or dedicated servers that run the cPanel application. Redirects are just a mouse click or two away from the menu item of the same name, and so far as I can see they work … worth a look-see.
Can anyone answer my question above??
I did already…
Thanks, I must have missed it at first…
[…] better to redirect the domain without the www to http://www.something.com … I got the tip off Tyler Cruz article Here’s how you can do […]
Hey Tyler there’s a lot more that needs to be done in wordpress to make it “more” SEO friendly. I believe there’s 4 pages of the same content by default by WP.. checkout my WP SEO post for the full scooop 😀
[…] Better PageRank? Redirect your domain to a www Do you notice that your domain for example has be accessed from something.com & http://www.something.com. To get a better PageRank, it’s better to redirect the domain without the www to http://www.something.com … I got the tip off Tyler Cruz article […]
[…] explanation was personalized, in-depth and instructional. He gave step by step advice about installing a 301 redirect and a clear explanation of what this should accomplish. His writing style works for me. It is a bit […]
Yeah that’s another SEO issue that can be fixed with a wordpress plugin called WWW Redirect.
You can read about it at http://www.makewickedmoney.com/the-top-7-wordpress-plugins-for-seo
I think it does it through htaccess though so you might not be interested in it…
[…] also recommend for Anthony to read my posts on Canonical URLs and Putting the Cart Before the Horse which are two easy yet very beneficial improvements he can […]
[…] also recommend for Anthony to read my posts on Canonical URLs and Putting the Cart Before the Horse which are two easy yet very beneficial improvements he can […]