'Block certain country using .htaccess
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.
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jon Lin |