iRead, iLearn, iWrite. Hence, iBlog.

For Indian Military, Nuclear & Space matters, visit:

Friday, March 14, 2008

Make site accessible without the www


In order to follow what I am explaining here, you would need to read my previous post first.


Configuring a Free Domain Name with your blog


Please read that before you read the following.


You have successfully configured your domain name with your blog hosted by Blogspot (Google). However, you will find that people will need to add the www to your address in order to access your site. This is especially true if you are using a free domain name registrar like co.cc or uni.cc. If someone makes the mistake of not adding the www to the url (site address), then in all likelihood, one would encounter a message in the browser window that would say "Server not found" or "Could not locate remote server", depending on the browser you are using (the only exception being Safari). If there could be a way to let people visit your site - www.shubhspace.co.cc, without having to add the www, then people would find it a lot more convenient to visit it (less letters to be typed in your site’s address), resulting in your blog becoming more accesible.



One solution to this problem is to employ the URL redirection method. A visitor types in shubhspace.co.cc and the person is automatically redirected to www.shubhspace.co.cc. Of the many re-direction methods available, we will see how you can perform the redirection with HTTP status code 301 (301 redirect). The other redirection methods are often employed by phishing sites to run their scams. So a 301 redirect is the only one that search engines approve of. So in this post we shall see how to perform a 301 re-direct.


The idea behind this is that you assign your domain name (shubhspace.co.cc, in my case) to a host that allows 301 re-direction. Once this is done, you enable the 301 redirection so that requests for shubhspace.co.cc gets redirected to the subdomain www.shubhspace.co.cc, that is located on a different host (Blogspot). As a result any visitor trying to access my site by typing in shubhspace.co.cc will be automatically re-directed to my actual site www.shubhspace.co.cc. He would thus be spared the trouble of punching the keyboard 4 times to visit my site (w-w-w and ’.’).


In order to do so, we would need a free web-hosting site that allows 301 redirects (I like to find ways of doing everything for FREE!!). One such hosting service is www.axpsace.com. Signing up for their service is another complete no-brainer. You may check out their features here. Since axspace has offered you the use of the cpanel interface, your job of redirecting is extremely simple. When you first log into your cpanel interface it would look something like this.


(Click on the image to view a large sized image)


cpanel interface


If you scroll down, you will see an section title Domains. In that you would see a link titled Redirects.


Domains


Clicking on it will take you to the page where you can redirect your site example.com to www.example.com. In my case, I select the Permanent (301) option from the drop down menu. For the domain name shubhspace.co.cc, I add the redirects to address as www.shubhspace.co.cc. Once done click on the Add button.


(Click on the image to view a large sized image)


301 redirect


On clicking on the Add button you shall be taken to the page that will inform you that all requests for shubhspace.co.cc will be redirected to www.shubhspace.co.cc


(Click on the image to view a large sized image)


20080314visitwithoutwww04


Clicking on the Go Back button will take you back to the page where you had entered the details. But now it will show you the list of redirected addresses in your account.


(Click on the image to view a large sized image)


redirect list


Your work in your Axspace control panel is over. You may safely log off.


Log into your EveryDNS account. In your domain records, add an A-Record, pointing shubhspace.co.cc to Axspace’s IP address - 66.49.222.169


add A-Record


Once you click on the Add Record button, your updated domain records would look like this.


domain records


(I have blanked out the unrelated domain records to prevent any confusion)


Wait for around 24 hours. Now when you would type in shubhspace.co.cc, you will be automatically redirected to www.shubhspace.co.cc.


If you choose to do a 301 redirect using a Host that does not have a cpanel account interface, but allows you to modify the .htaccess file (Apache web servers), then you may add this piece of code to it.



RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^shubhspace.co.cc$ [NC]
RewriteRule ^(.*)$ http://www.shubhspace.co.cc/$1 [R=301,L]


It too will do the same thing (just replace shubhspace.co.cc with the appropriate address).


If you got any query related to the post, feel free to drop in a comment. I shall try to address it to the best of my ability.

Further Reading

What do HTTP status codes mean? - An article from Google’s Webmaster Help Center

Status Code Definitions - Learn more about 3xx HTTP status codes

How to setup a 301 Redirect - This article will tell you about the different ways of performing a 301 redirect

Wkipedia entry about URL re-directions