例如,我试图将我的访客重新引导到
http://localhost/site/test.php?lang=en_US
if (isset($_COOKIE['country']))
{
$country = $_COOKIE['country'];
header('Location: test.php?lang=en_US');
if ($country == "NO"){
header('Location: test.php?lang=no_NO');
}
}
else
{
header('Location: test.php?lang=en_US');
}
但我在firefox中发现了一个奇怪的错误:
The page isn't redirecting properly
找到了解决方案:
if (!isset($_GET['lang']))
{
if (isset($_COOKIE['country']))
{
$country = $_COOKIE['country'];
$redirect = "en_US";
if ($country == "NO"){
$redirect = "no_NO";
header('Location: crime.php?lang='.$redirect);
}
if ($country == "EN"){
$redirect = "en_US";
header('Location: crime.php?lang='.$redirect);
}
}
else
{
header('Location: crime.php?lang=en_US');
}
}