Header Ads

Redirecting Naked Domain to its www subdomain : A Problem in Blogger Custom Domain Redirection


Many of you must be having a blog on blogger/blogspot. There is a option in the blogger settings section, to host your blog on a custom domain.

If you want to host your blog on a domain name of your choice, first you need to register that domain name and then set it to point to blogger servers using a cname record. You will get a detailed tutorial for this on blogger help section here.

But blogger allows only the use of a subdomain to host your blog. You cannot host your blogger blog on a naked domain like http://example.com. You need to create a subdomain like http://www.example.com or http://blog.example.com to host your blog. The process of creating a cname record for a domain is explained here.

And then there is a option to redirect the naked domain on its subdomain you are using for your blog.

Now, the problem arises here. If you've registered you domain name through blogger, then this redirection option of redirecting the naked doamin on the used subdomain will work fine. Otherwise, it will not work.

If you already own a domain name and want to have your blogger blog hosted on that, then first you'll have to create a subdomain for this. And host your blog on this subdomain by using the cname records in the DNS control panel of your domain.

Now, to redirect your naked domain on this subdomain you'll need a bit of web space to host files for redirection.

Remember, if you use a separate hosting with your domain, you'll need to update the name servers of your domain name and also you will have to create the cname once again using your hosting control panel.

You'll either have to create a redirect page or a .htaccess file to rediect your named domain - http://example.com to your subdomain on which your blog is hosted - http://www.example.com

To use a redirection page, create a .html file and name it index.html and paste the following meta tag in the head of this file.

meta http-equiv="refresh" content="8; url=http://www.example.com"

Don't forget to change the example.com with your domain name.
The field content="8" means that the page will take 8 seconds to redirect. You can change it to "0"as well.

Upload this file in the root directory of your domain and its done!

The rediection page option is highly not recomended because its not very fast and also creates some confusion with the search engines.

Rather, you should use the .htaccess file to do this.
To create an .htaccess file to redirect your domain on its subdomain, just open notepad on windows.
Save this blank document as .htaccess and make sure that while saving, the save as type field is set to "all files".

Now paste the following text in this document and save it again.

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

Don't forget to change the example.com with your domain name. This is your .htaccess file which will redirect your naked domain to your blog's address on a subdomain.

Now, host this file on the root directory of your domain. While doing this, keep in mind the following things...

1. Your hosting should be on linux server. .htaccess works only with apache.

2. Upload the file in ASCII mode. DO NOT upload it in binary mode.

3. After the upload CHMOD the permissions of this file to 644.

Now, relax, your naked domain will be redirected to your blog's address in a few hours. Enjoy!