Redirect to different subfolders according to geolocation without affecting SEO
I want to open different pages by default in different countries. But It affects SEO of main URL.
Like my website is example.com. I want to open this URL in India and example.com/abc outside India by default.
But my SEO of example.com should not be affected. how can I achieve that? I have written following script for this on top of index page.
<script>
$.ajax(
url: 'https://ipapi.co/json/',
dataType: 'json',
async: false,
success: function(data) {
if(data.country_name.toUpperCase() != "INDIA")
window.location.href = "/abc";
}
);
</script>
It is navigating fine, but it is deindexing example.com from google
You can use rel=alternate to indicate that the example.com/abc is for outside India and that example.com is the default version. This way a user in India will find the example.com in his search results and any other user will see example.com/abc in his search results while in another country.
Checkout the google webmaster blog about rel=alternate.
I applied a different solution which is working fine now.
I created a script.js file for above redirection script and added it to my index page. Then I disallowed this script.js file for googlebot in robots.txt
Comments
Post a Comment