Mobile app version of vmapp.org
Login or Join
Carla537

: How can I block my website in other countries? Lets assume my website is mywebsite.com. I need to block the website for all the countries except India. But we need to handle the block gracefully,

@Carla537

Posted in: #301Redirect #CanonicalUrl #Ecommerce #Seo #WebDevelopment

Lets assume my website is mywebsite.com. I need to block the website for all the countries except India. But we need to handle the block gracefully, i.e. showing a page that right now the site is not providing services in their country.

Page on my website visible in India:
mywebsite.com/category.php

When someone outside India opens the website they should see the following URLs:
mywebsite.com/world/category.php

Kindly note that Google Search should always show the URLs without "world" in there.

Following are the solutions I have on mind:

Scenario: Someone tries to open mywebsite.com/category.php from US.
The code will check for the IP location and the user would be redirected to mywebsite.com/world/category.php

Solution1: Add no follow and no index tags on mywebsite.com/world/category.php so that Google does not index this page and use a 302 redirection. This page will be served to everyone from outside India.

Solution2: Add a 302 redirect from mywebsite.com/category.php to mywebsite.com/world/category.php
and also add canonical on mywebsite.com/world/category.php as website.com/category.php

Problem in this approach is loop for Google bot, first we are doing a redirect and then we are putting a canonical to the one which as redirected. Sounds wrong to me but I am not sure.

Note: This question is related SEO strategy. I want your suggestions on my SEO strategy. I do not want any technical solution for redirection from .htaccess or IP blocking outside India traffic .

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Carla537

2 Comments

Sorted by latest first Latest Oldest Best

 

@Merenda212

Filter visitors by .htaccess:

RewriteEngine On

RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^IN$
RewriteRule ^(.*)$ Mywebsite/Indiapage.php [L]


And for the rest you redirect to world/worldpage

10% popularity Vote Up Vote Down


 

@Turnbaugh106

Here is the ip range for India www.nirsoft.net/countryip/in.html
use above address and codes below (you need to enter ip ranges by yourself)

<?php
$deny = array("1.6.0", "1.22.0", "223.224.0");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
header("location: mywebsite.com/world/category.php );
exit();
} ?>


or this

if(strpos($_SERVER['REMOTE_ADDR'], "14.102") === 0))
{
die();
}


you need to do some work but this is the way that I can think of. You can try use wildcard for php (*) for the similar ip ranges

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme