我想限制访问URL或地址的一个或多个特定国家/地区IP,例如“ /cart.php?a=checkout”。htaccess和Geo-IP mod如何做到这一点?
例如,您可以使用以下代码:
<FilesMatch "^(cart\.php|viewinvoice\.php)$">
SetEnvIf GEOIP_COUNTRY_CODE DE BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE IN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE UA BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE EC BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE VN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE AM BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE LV BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE US BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE TR BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE FR BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE SA BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE PL BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE NL BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE SG BlockCountry
Order allow,deny
Allow from all
Deny from env=BlockCountry