使用htaccess和GeoIP的特殊地址或URL所在的国家/地区

问题描述 投票:0回答:1

我想限制访问URL或地址的一个或多个特定国家/地区IP,例如“ /cart.php?a=checkout”。htaccess和Geo-IP mod如何做到这一点?

.htaccess block access-denied geoip restrict
1个回答
0
投票

例如,您可以使用以下代码:

<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
© www.soinside.com 2019 - 2024. All rights reserved.