Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.

Other Posts
Projecter Keyboard
Weird Story - Selling his life on Ebay

Set your URL to with or without www

Posted by andrew on February 11th, 2007

To www or not to www, that’s the question. Different people have different preference. I personally would like to just type my domain name without the www. For SEO purposes, it’s better to choose 1 and stick with it - otherwise you might end up with different Page Ranks for each URL (with and without). So what can you do to fix this?

Step 1: Adjust settings using Google Webmaster Tools
Google Webmaster Tools is useful to adjust the way Googlebot crawl and index your site, so sign up with them if you haven’t. After logging in to Google Webmaster Tools, look under the “Preferred Domain” menu (on the left sidebar), choose the appropriate settings for your site.

Step 2: Set up a 301 Redirection
After you decided whether to include www or not, you have to make sure all visitors will end up at the same url. There are few ways of which this can be done using 301 redirection.

First step is if your site is hosted on a Linux server with Apache Mod-Rewrite module enabled.

a) redirect all http://www.yoursite.com to http://yoursite.com
Go to your root directory and add the following code to your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com$ [NC]
RewriteRule ^.*$ http://yoursite.com%{REQUEST_URI} [R=301,L]

b) redirect all http://yoursite.com to http://www.yoursite.com
Go to your root directory and add the following code to your .htaccess file:

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

Note: Make sure you chance yoursite.com in the code to your own site URL!

Alternative Step: Use A Wordpress Plugin (For Wordpress Users)
If you are not hosted on Linux server, or if you’re not using Apache, or if you are confused with editing the .htaccess file, use this plugin called WWW Redirect. You can set whether to have the www or not from your Wordpress Admin panel once you set this plugin up successfully.

Hope it works for all of you out there.

Reference: John Chow - Setting The Preferred Domain

 



Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!