Welcome To eMonetized.com - A Social Media, Internet Advertising and Affiliate Marketing Blog.

301 Website Redirect: non-www to the www

Posted on May 18, 2007 by Tim Schroeder

One of the first things I’ve done during the setup of the eMonetized.com website is to use a 301 redirect to automatically redirect the non-www URL of this website (emoneitzed.com) to the www version (www.emonetized.com).

What is a 301 Redirect:

A 301 Redirect basically tells the the search engines that a website or particular URL has “moved permanently.” If you want to know more of the technicals, just “Google it”.

Why 301 Redirect non-www Pages to There www Versions:

Many search engines such as Google see the two different versions of your URL as two different webpages. The main reason you don’t want this is for SEO / link popularity issues. All websites linking to your non-www version of your site wont increase the Google Page Rank of the www version.

Using a 301 Redirect in this manner will ensure that even links pointing to the non-www version of your webpage will be seen and credited accordingly as the www version.

How to 301 Redirect non-www Pages to There www Versions:

1. First make sure that your hosting provider has the Apache Rewrite Module turned on. Most do.

If you have access to the httpd.conf file on your server then you can actually enable the rewrite module yourself. In the httpd.conf file uncomment the following line: “LoadModule rewrite_module modules/mod_rewrite”.

Save and restart the server (always make backups first!).

2. Import the .htaccess file from your website’s root web folder to a folder on your machine where you can edit it. I strongly suggest also making a copy of the original .htaccess file in the case you have to switch back to the original version.

3. Open the original .htaccess you downloaded in Notepad.
Add the following code into the .htaccess file (don’t overwrite any existing code). Also be sure to substitute “yourwebsitedomain123” with your own website information but touch nothing else.

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

Finally, save the file, upload it to your server and test it by typing to non www version of your domain into your web browser. That’s it!

Any problems? Just revert the .htaccess file back to the original which you should have saved a copy of on your hard drive. Reply here and I’ll help if I can.

Did you enjoy this post? Please Subscribe via RSS or eMail.

5 Responses to “301 Website Redirect: non-www to the www”

  1. Jack Book

    - 22nd Jun, 07 04:06am

    hi Tim,
    thanks for your tips. about .htaccess, do you have any idea how can i use it on windows? i know it’s for unix family, but any idea how to have .htaccess or similar on my windows?

    thanks

  2. Tim Schroeder

    - 22nd Jun, 07 10:06pm

    Hi Jack,

    I not real sure about the answer to that question. I’ll have to look into it.
    Meanwhile, if any one knows the answer to his question please let us know.

  3. Andy Beard

    - 23rd Jun, 07 12:06am

    The easy way is to use (at least I think it will work)
    http://fucoder.com/code/permalink-redirect/

    It isn’t ideal for a high traffic site

  4. Souvik Banerjee

    - 18th Jun, 08 05:06am

    I’ve redirected my website from “http://www.souvikbanerjee.com” to “http://souvikbanerjee.com”, using the following code,

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.souvikbanerjee\.com
    RewriteRule ^(.*)$ http://souvikbanerjee.com/$1 [R=permanent,L]

    After doing this, when I am clicking on archives or categories it is showing, “Not Found”. Now what change should I make in my .htaccess file to make all these work? (You can visit my site for reference.)

  5. Matt

    - 10th Sep, 09 07:09am

    Thanks helped me out, and the code worked!

What Do YOU Think?

© 2007-2009 eMonetized.com Affiliate Marketing Blog. | SUBSCRIBE