Redirect IP-ranges
Simple snippet for redirecting ip-ranges.
$aMyIPRange[] = '127.0.0.3/127.0.0.3';
$aMyIPRange[] = '127.0.0.0/127.0.0.10';
redirectIpRanges($aMyIPRange, 'http://heise.de/');
function redirectIpRanges($aIPRange, $sDestination)
{
foreach((array) $aIPRange as $sRange)
{
$aIPRange = explode('/', $sRange);
$iStart = ip2long($aIPRange[0]);
$iEnd = ip2long($aIPRange[1]);
$iIP = ip2long($_SERVER['REMOTE_ADDR']);
if ($iIP >= $iStart && $iIP <= $iEnd)
header('Location: '.$sDestination);
}
}
Url: http://sklueh.de/2013/09/php-verschiedene-ip-ranges-umleiten/
Language: PHP | User: sklueh | Created: Sep 16, 2013 | Tags: ip ranges redirect