2017-08-29 75 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