Server Response Code Fixes: How to Redirect non-www to www

by claire on June 9, 2009

This post is in response to Problem #1 in post: 4 Common Server Response Codes and 4 Problems to Fix.  Seasoned SEOs get this stuff, so if you’re seasoned, skip it… but if you’re a n00b, read on for the steps to fix one of the most common issues I see on established websites.  If you’ve answered “No” to the question, “Does the Non-WWW Domain Address 301 Redirect to the WWW URL?” Then you need this fix.  Have your response code ready from you server header check, and follow the steps below for the code your site is sending the search engine or browser:

  1. If your response code is 200:
  2. You need to implement a redirect.  If you’re on an Apache server (UNIX), this is really easy to do using .htaccess.FTP to your site’s root html folder to see if there’s an existing .htaccess file.  If so, open it using a text editor (I like Textwrangler for Mac and EditPlus for PC).  If there isn’t an existing .htaccess file, start a new text document and save it as “.htaccess” (without any extension, like .txt).Add this snippet of code to the file, changing yourdomain.com to the url of your site:

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

    Upload the file to your domain at the root.  That’s it!  Now, run the check again in the server header checker, and if all goes well, you should see a 301 response code.

  3. If your code is 302:
  4. Most commonly, it’s because you’re on an iis server (microsoft).   You can tell what type of server you’re on using the server header checker, as well.  If you’re on iis or nginx, it’s a little more complicated than updating your .htaccess file, and it’s more than likely that it will be easiest to accomplish by contacting your webhost (at least that’s how I’d handle it :) ).  If you’re up to tackling it, Google “301 redirect iis”.

    If you’re on Apache, follow the same steps for adding a redirect to your .htaccess file, as detailed above in step #1 for the 200 server response code.

Share and Enjoy:
  • Digg
  • Sphinn
  • TwitThis
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Propeller
  • Reddit
  • StumbleUpon
  • Yahoo! Buzz

Leave a Comment

Previous post: 4 Common Server Header Response Codes and 4 Problems to Fix

Next post: Facebook Suggesting Dots ( “.” ) in New Username Profile URLs – Bad or Good for SEO?