我試圖在我的joomla 2.5安裝上實現Geoip服務。Joomla GEOIP Maxmind重定向循環
我想要的是,網站http://www.example.com重定向到法國語言的http://www.example.com/fr。
我已經將maxmind geoip包含在模板文件的標題中。但重定向在循環中執行。
這是我如何執行該文件:
<?php include_once('templates/my_template/geoip/country-redirect.php'); ?>
這是我的重定向腳本:
$gi = geoip_open('templates/my_template/geoip/GeoIP.dat', GEOIP_MEMORY_CACHE);
$country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
// prints the country code your visitor is in
if($country == 'FR')
{
header('Location: http://www.example.com/fr');
exit();
}
else if($country == 'US')
{
header('Location: http://example.com');
exit();
}
// the end
geoip_close($gi);
我想是因爲劇本是由它將執行每次模板文件模板執行被加載,所以在重定向時它會連續執行這個腳本。
如果運行/ FR或最有可能我們( example.com)具有相同的腳本,請在重定向之前檢查您的當前位置,否則您將永遠重定向... – Ihsan 2013-03-25 09:38:29
您是否有此示例腳本? – 2013-03-25 09:45:58