Saket Jajodia

Tecko Blog..!!

Follow me on Twitter @

How To Stop Your Blogger Blog From Getting Redirect To Country Level Domain (ccTLD)

Early last month in February Google started redirecting all blogs to local country code Top-Level Domain (ccTLD), the blogs which are hosted on Blogger.com and using free BlogSpot sub-domain. For instance if you visit example.BlogSpot.com from India (or using any Indian IP address) then it will get redirected to example.BlogSpot.In or if you visit from UK (or by using any UK IP address) then it will get redirected to example.BlogSpot.Co.UK.

Till now it live in around 15 countries mention below:
Argentina (blogspot.com.ar), Australia (blogspot.com.au), Brazil (blogspot.com.br), Canada (blogspot.ca), France (blogspot.fr), Germany (blogspot.de), India (blogspot.in), Italy (blogspot.it), Japan (blogspot.jp), Mexico (blogspot.mx), New Zealand (blogspot.co.nz), Portugal (blogspot.pt), Spain (blogspot.com.es), Sweden (blogspot.se), UK (blogspot.co.uk)

BlogSpot.In

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.

So if you don’t want your blog to get redirect to country specific domain, I have posted an article with the solution on very first day (when this started happening) but it cannot support all country specific domain as for that you need to update your code every time when a new country get added in the list.

I was trying to make this dynamic so that you don’t need to update it even once but sue to lack of knowledge about JavaScript and time I couldn’t able to make one such code. But today I noticed an article by Amit where he has made a JavaScript code which can solve the problem but only in Firefox (and might in few other browsers also) because of some flaws in other browsers.

As I went through the code I got that it might not work and when I tested that code in Google Chrome, that code was taking me to a different blog which is using blogspot domain. Tt took me around couple of hours to solve that code. Here is the code which will work correctly and tested in (latest versions of) all major web browsers.

Just go to Blogger Dashboard –> Design/Template –> Edit HTML and then add this below code just after starting <head’> tag

<script type='text/javascript'>
if (document.location != '<data:blog.canonicalUrl/>'){
var dom = document.location.hostname;
var path = document.location.pathname;
var dot = dom.split(".");
var ex = dot[2];
var ex2 = dot[3];
if (ex != "com" || ex2 != null){
var name = dot[0] + ".blogspot.com/ncr";
window.location.replace("http://" + name + path);}}
</script>

And Google has also remove their default 404 error page form all Blogger blog and started showing current template of that blog with this error message “Sorry, the page you were looking for in this blog does not exist.” so that people can easily redirect their blog to blogspot.com domain using JavaScript.

If you have any question or facing a problem with the same, let me know by commenting below.

Reply

Please use your original name while commenting, Thank you..!!








Designed by Blogger Templates and Blog and Web