How to block or allow countries using GeoIP and .htaccess
From Brian Nelson Ramblings
Revision as of 19:36, 5 June 2015 by Brian (Talk | contribs) (Created page with "==How to block or allow countries using GeoIP and .htaccess== First you will want to to install GeoIP and mod_geoip ===Block Countries u...")
Contents
How to block or allow countries using GeoIP and .htaccess
First you will want to to install GeoIP and mod_geoip
Block Countries using GeoIP and .htaccess
The following will deny from China, North Korea, South Korea
GeoIPEnable On # Put countries to deny here SetEnvIf GEOIP_COUNTRY_CODE CN DenyCountry SetEnvIf GEOIP_COUNTRY_CODE KR DenyCountry SetEnvIf GEOIP_COUNTRY_CODE KP DenyCountry Allow from all Deny from env=DenyCountry
Allow Countries using GeoIP and .htaccess
The following will allow only from US, Canada and Mexico
GeoIPEnable On # Put countries to allow here SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry SetEnvIf GEOIP_COUNTRY_CODE CA AllowCountry SetEnvIf GEOIP_COUNTRY_CODE MX AllowCountry Deny from all Allow from env=AllowCountry