joomla 2.5 インストールに Geoip サービスを実装しようとしています。
私が欲しいのは、ウェブサイト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);
スクリプトはテンプレートから実行されるため、テンプレート ファイルが読み込まれるたびに実行されるため、リダイレクト時にこのスクリプトが継続的に実行されると思います。