2017-08-29 36 views
-1

订单拒绝添加IP地址,允许 所有 拒绝允许从xx.xxx.xxx.xxx xx.xxx.xxx.xxxhtaccess的 - 允许动态地使用PHP

是否有可能增加新的IP中在htaccess中使用PHP允许的IP列表? 或将php数据传递给列表?

感谢

+0

最基本的研究,如打字_“PHP写的htaccess” _到谷歌,会显示你,这是“可能” ... – CBroe

回答

0

您可以在以下

Use PHP to Dynamically Add To .htaccess File?

写用PHP你的htaccess文件等,但它是高度不建议。另一种方法是在php脚本中检查受限制的ips。

$restrictedIPs = array() // array of ips which you want to block 
if(in_array($_SERVER['REMOTE_ADDR'], $restrictedIPs) || in_array($_SERVER["HTTP_X_FORWARDED_FOR"], $restrictedIPs)) { 
    exit("You are not allowed to access the content"); 
} 
+0

谢谢主席先生,,生病使用替代解决方案。 。 – misdirection