# How to direct visitors from certain countries to a different landing page?



## Scadobop (Jul 13, 2015)

What is the best way to accomplish this? For example, say if I want to block China, Vietnam and Nigeria (example) from accessing my main website but I want them to instead see a different site or content, how can I do this? I am using nginx as my web server if it matters.

I think I will need some sort of geoip tool installed on the server and if the request comes from a certain group I want it to show a different page than my normal website. This will be for blocking orders but I do not want them to get a website timeout or standard 404 error that they might see if just outright blocked. Instead I want them to see the site but with it will be a single page stating we're out of stock or can not accept orders from that country or something like that.


----------



## Bruce (Jul 13, 2015)

geoIP tools have code to help you

http://www.ip2location.com/tutorials/redirect-web-visitors-by-country-using-php-and-mysql-database


----------



## Jive (Jul 13, 2015)

Nginx itself could probably handle this with it's geoip module.


http://nginx.org/en/docs/http/ngx_http_geoip_module.html


A quick Google search turned up this guide: http://nginxlibrary.com/ip-based-country-blocking/(Which looks like it'd work on Debian/Ubuntu)


Its contents is kinda brief and not entirely specific to your needs but should be able to be modified to show the landing page you mentioned vs a simple 403 forbidden response.


----------



## Clouvider-Dom (Jul 19, 2015)

You can use GeoIP on the web server level or in your PHP scripts.

More blunt way would be blocking IP by country by CSF, but it's not the most accurate and it won't redirect but they just won't be able to connect.


----------

