Disable 302 Redirection to Country Specific Domains

As many of you may know, Google is continuously releasing updates in order to improve its services. In Jan 31, 2012 Google started Country-Specific url redirect to blogger. What means that? - If you are viewing a blog with address example.blogspot.com from France (FR), then you'll be redirected to .fr domain - example.blogspot.fr. Similary, if you are viewing from United Kingdom it will be redirected to example.blogspot.co.uk! It is happening so that Google can easily block the content which is not appropriate for a specify country according to the law of that country and can easily server that same content in other country without any issues.

However, this redirection is "302 Redirect" which is a temporary change and not a 301 redirect which is a permanent change of address.

This country based URL redirection does mean some negative consequences to your blog! 

With that redirection your Alexa Traffic Rank will be separated to different domains. So, for better search engine optimization (SEO), you can add the following piece of code to your template and it will always serve the .com address to your visitors.

Go to Design -> Edit HTML. Click on "Expand widget templates" and search for "</head>".
Now copy and paste the following code BEFORE the </head> tag.

<script type="text/javascript">
var blog = document.location.hostname;
var slug = document.location.pathname;
var ctld = blog.substr(blog.lastIndexOf("."));
if (ctld != ".com") {
var ncr = "http://" + blog.substr(0, blog.indexOf("."));
ncr += ".blogspot.com/ncr" + slug;
window.location.replace(ncr);
}
</script>

Save your template and you are ready!

Comments

  1. This doesn't work if they are on a mobile device and the "?m=1" is added to the URL. Got a fix for that?

    ReplyDelete
  2. Hi Joe, I don't know how to fix that..
    This is interesting.
    I will make a little research about this issue

    ReplyDelete
  3. this code still work man ??
    but, thanks for sharing ...

    ReplyDelete
  4. I don't know really :) Backup and try it. You'll see changes in Traffic Stats immediately

    ReplyDelete
  5. in my blog it works.thanks for sharong

    ReplyDelete
  6. This doesn't work. can you tell me how the Javascript can access Blogger server to disable 302 ridrect? :D

    ReplyDelete
  7. Thanks for sharing. Works great on my blogspot page.

    ReplyDelete

Post a Comment

Before leaving a comment, please read our Terms of use!