【发布时间】:2016-08-09 06:25:56
【问题描述】:
我有一个名为 smarkmart 的网站。我想以三种方式重定向它。 1. 在印度,它应该在 www.smarkmart.in 2. 在美国它应该在 www.smarkmart.com 3. 其他的应该在 www.smarkmart.com 上
这是我的重定向代码-
session_start();
require 'geoplugin.class.php';
$geoplugin = new geoPlugin();
$geoplugin->locate();
if (isset($_SESSION['pricetype'])) {
unset($_SESSION['pricetype']);
}
// create a variable for the country code
$var_country_code = $geoplugin->countryCode;
// redirect based on country code:
if (!isset($_SESSION['pricetype'])) {
if ($var_country_code == "US") {
header('Location: http://www.smarkmart.com');
$_SESSION['pricetype'] = "priceinr";
}
if ($var_country_code == "IN") {
header('Location: http://www.smarkmart.in');
$_SESSION['pricetype'] = "priceusd";
} else {
header('Location: http://www.smarkmart.com');
$_SESSION['pricetype'] = "priceinr";
}
}
$pricetype = $_SESSION['pricetype'];
这会导致无限循环。任何帮助,将不胜感激。提前致谢。
【问题讨论】:
-
这不是 SEO 和用户友好的。看看:support.google.com/webmasters/answer/182192?hl=en