Posted on Monday 18th of June 2012 at 12:38 in Tutorials

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?

blog comments powered by Disqus
Who is Seopher?

This is me. I'm a 27 year old web
developer, blogger and entrepreneur
from near London.

I've done work for people like
Samsung, Vauxhall, Cadburys,
Chevrolet, Center Parcs and TKMaxx.

I've been running this blog since 2006
and have reached more than
1.7 million readers

I'm passionate about the web, heavy metal, zombies and cats.

Seopher
Subscribe to the RSS Feed

Stay up to date with Seopher.com by subscribing to the RSS feed, either in your browser or subscribe via email using the form below

Updates by Email

By subscribing by email you’re also subscribing to the Seopher.com newsletter; a periodical email outlining new reviews, competitions and other subscriber-only content

  • ReviewMeReviewMe
  • buy 125x125 advert for $50 pcm
Want to give your product/website exposure?

Paying for a featured review is a great way to give your product, service or website exposure. For as little as $75 you can have a full review on the site forever.

Advertising Bundle! Review + Banner = $100

Buy a review and get a 125x125 advert half price. Your banner gets displayed on over 541 pages for a full month.