重定向循环在Switch Case头(位置)


Redirect Loops in Switch Case with header(location)

<?php
$rexgeoip = new RexGeoIp;
$iso = strtoupper( $rexgeoip->getCountryIso() );

    switch ($iso) {
        case 'DE':
                header("Location: http://www.domain.de/en/",TRUE,301);
            break;
        case 'AT':
                header("Location: http://www.domain.de",TRUE,301);
             break;
        case 'CH':
                header("Location: http://www.domain.de",TRUE,301);
             break;
        default:
                header("Location: http://www.domain.de/en/",TRUE,301);
        break;
    }
}
echo "<!-- your iso is $iso -->";
?>

这是我的代码,重定向到相应的域路径。我将DE的大小写改为/en,因为我在德国,想测试重定向。但是每次我使用DE ISO时,我都会得到一个"多次重定向"超时。如果我从美国或亚洲通过web代理连接,也会发生这种情况。

有什么想法或建议吗?

de添加到路径中,不要在负责http://www.domain.de/de/http://www.domain.de/en/的脚本中重定向:

<?php
$rexgeoip = new RexGeoIp;
$iso = strtoupper( $rexgeoip->getCountryIso() );

switch ($iso) {
    case 'DE':
            header("Location: http://www.domain.de/en/",TRUE,301);
            exit;
        break;
    case 'AT':
            header("Location: http://www.domain.de/de/",TRUE,301);
            exit;
         break;
    case 'CH':
            header("Location: http://www.domain.de/de/",TRUE,301);
            exit;                 
         break;
    default:
            header("Location: http://www.domain.de/en/",TRUE,301);
            exit;
    break;
  }
}
echo "Script never gets here";
?>