我使用下面的代码片段来重定向一组IP地址。我想知道如何将整个IP地址范围/块添加到我的无用数组中……
<?php // Let's redirect certain IP addresses to a "Page Not Found"
$disallowed = array("76.105.99.106");
$ip = $_SERVER['REMOTE_ADDR'];
if(in_array($ip, $disallowed)) {
header("Location: http://google.com");
我有一个登录系统,我试图使其尽可能安全。尝试十次失败后,我想阻止该IP地址。如何在PHP中打开一个文件,并在我的.htaccess文件中添加一行来阻止IP地址?这是我的.htaccess文件:
# Turn on RewriteEngine
RewriteEngine on
# Block IP addresses with too many failed attempts
RewriteCond %{REMOTE_ADDR} ^217.172.179.*$ [OR]
RewriteCond %{REMOTE_ADDR} ^217.172.180.*$
RewriteCond %{REQUE
我正在将此代码复制到我的.htaccess文件中,但它似乎没有将IP重定向到站点
RewriteEngine On
RewriteCond %{HTTP_HOST} ^XXX\.XXX\.XXX\.XXX # I have the IP correct
RewriteRule (.*) http://www.example.com/$1 [R=301,L] # I have the domain name correct
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
我使用了基于IP的限制,只允许少数设备访问我的站点。我在htaccess文件中使用了以下代码:
deny from All
alloy from xxx.xxx.xx.xx
这一切运行正常,我只能通过我的移动设备访问该网站。但过了一段时间,我的手机IP地址发生了变化,我无法从我的设备访问该网站。
那么,有没有什么万无一失的方法来限制站点访问某些设备,即使它的IP发生了变化?