Reputation: 2469
Is there a simple and reliable way to block certain countries using .htaccess?
Simple means no IP range block lists - they need to be updated once in a while and can be quite long.
I understand, that it wouldn't apply to proxies.
Upvotes: 1
Views: 2523
Reputation: 143886
Easiest is probably using the GeoIP Apache module. After installing and configuring you just need to do something like this in your htaccess file:
GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat
SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
# ... place more countries here
Deny from env=BlockCountry
Upvotes: 2