我正在使用以下代碼段重定向一組IP地址。我不知道我怎麼會去加入的整個範圍/ IP的塊地址到我的dissallowed陣列...如何用PHP重定向整個範圍/ 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");
exit;
}
?>
我嘗試使用「76.105.99。*」,「76.105.99」,「76.105 .99.0-76.105.99.255「沒有任何運氣。
由於其他原因,我需要使用PHP而不是mod_rewrite和.htaccess。
我認爲你需要重新設計你的比較代碼來了解你將要使用的縮寫。 – Lazarus 2009-09-23 15:59:49