How to 301 redirect non-www to www using an htaccess file
In a rather ridiculous turn of events, Rob from HitTail (who I'm writing a review for currently) gave me a nudge to let me know that I wasn't forcing www on non-www visitors.
The stupid thing is, I probably haven't even looked at the domain configuration for this site since it was registered (2006) and certainly haven't done anything with the .htaccess file since I wrote the clean URL rules (2007 maybe?). As such, despite my professional abilities and knowledge, this very site was heavily disadvantaged in SEO terms.
Anyway, me being stupid aside, here's how you add the rule to your .htaccess file in order to redirect non-www traffic to be www (so anyone who visits website.com is redirected to www.website.com).
If you don't know what an htaccess file is, then hit Google and do a bit of reading. They're not really things you should dabble with without some level of understanding because you can really upset the harmony of your website if you're not careful (indeed, stopping any pages being displayed at all to anyone).
Okay, so why would you want to redirect non-www to www?
If you allow your website to work with www and without, search engines such as Google will treat the two sites as separate. So you might find that www.website.com/article also has website.com/article listed, therefore it's deemed duplicate information and both pieces of content are justifiably discredited.
So telling the server to only return www.website.com will ensure that you only have one instance of each page indexed. Therefore you'll get better rankings, get more visitors, make more money, sleep with sexy women/men and have a happy life. Guaranteed.
Enjoy this article? Why not subscribe to the full RSS feed?