Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我想使用htaccess阻止除office IP之外的所有IP地址_Php_Wordpress_.htaccess - Fatal编程技术网

Php 我想使用htaccess阻止除office IP之外的所有IP地址

Php 我想使用htaccess阻止除office IP之外的所有IP地址,php,wordpress,.htaccess,Php,Wordpress,.htaccess,我想阻止来自特定国家/地区的ip,但我需要使用htaccess或任何其他方式仅向该国家/地区提供少数ip地址的访问权限?编辑您的.htaccess文件 <ifModule mod_geoip.c> GeoIPEnable On #Add countries you wish to deny here SetEnvIf GEOIP_COUNTRY_CODE CO DenyCountry SetEnvIf GEOIP_COUNTRY_CODE EG DenyCountry Set

我想阻止来自特定国家/地区的ip,但我需要使用htaccess或任何其他方式仅向该国家/地区提供少数ip地址的访问权限?

编辑您的.htaccess文件

<ifModule mod_geoip.c>
GeoIPEnable On

#Add countries you wish to deny here

SetEnvIf GEOIP_COUNTRY_CODE CO DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE EG DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE HI DenyCountry

Allow from all
Allow from xx.xx.xx.xx

Deny from env=DenyCountry
</ifModule>

地理位置
#在此处添加您希望拒绝的国家/地区
SetEnvIf GEOIP_COUNTRY_CODE CO DenyCountry
SetEnvIf GEOIP_国家代码,如DenyCountry
SetEnvIf GEOIP_国家代码HI DenyCountry
通融
允许从xx.xx.xx.xx开始
拒绝来自env=DenyCountry
可在此处找到2位国家/地区代码列表:

也许用PHP更容易做到这一点?这可能会有所帮助-。记住,你永远无法阻止整个“国家”,人们使用代理和VP来绕过它。