Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I ban or restrict a country based on IP?

I get 6-10 sign ups from places like Nigeria and Ghana in Africa. I'm currently capturing IPs so is it possible to restrict a range of IPs from a specific country?

If I can retrict them does it make more sense to add this range to my .htaccess file or restrict them at the site level?

like image 871
Paul Avatar asked Nov 25 '11 15:11

Paul


1 Answers

You can get the maxmind database:

http://www.maxmind.com/app/mod_geoip

and use this code:

GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat

# Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(NI|GH)$
RewriteRule ^(.*)$ - [F]
like image 162
Book Of Zeus Avatar answered Sep 29 '22 19:09

Book Of Zeus