While 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:
# This block 301/permenant redirects from non-www to www URL for canonical URLs
Redirect permanent / http://www.tylercruz.com/
And as you can see, http://tylercruz.com now automatically redirects to http://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
(If you enjoyed this article or found it helpful, please take the 10-seconds it takes to Digg it below.)