0
<?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 时,我都会收到“多次重定向”超时。如果我通过美国或亚洲的网络代理连接,也会发生这种情况。

有什么想法或建议吗?

4

1 回答 1

0

添加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";

?>
于 2013-05-21T14:25:30.067 回答