I successfully install mod_geoip in my server. I test by using the following code & it show the right country
I want to block wp-login.php by using GeoIP. Only to allow for certain country by using .htaccess but seem to be not working. This is my code in .htaccess
The same code showed in http://dev.maxmind.com/geoip/legacy/mod_geoip2/#Allowing_clients_based_on_country
Any ideas what is wrong?
Code:
<?php
if (getenv(HTTP_X_FORWARDED_FOR)) {
$pipaddress = getenv(HTTP_X_FORWARDED_FOR);
$ipaddress = getenv(REMOTE_ADDR);
echo "Your Proxy IP address is : ".$pipaddress. " (via $ipaddress) " ;
} else {
$ipaddress = getenv(REMOTE_ADDR);
echo "My IP address is : $ipaddress";
}
$country = getenv(GEOIP_COUNTRY_NAME);
echo "<br />My Country : $country";
$country2 = $_SERVER['GEOIP_COUNTRY_CODE'];
echo "<br />My Country Code : $country2";
?>
Code:
<IfModule mod_geoip.c>
<FilesMatch "wp-login.php">
SetEnvIf GEOIP_COUNTRY_CODE CA AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE MX AllowCountry
Deny from all
Allow from env=AllowCountry
</FilesMatch>
</IfModule>
Any ideas what is wrong?