I'm about to use geoplugin.com on a site to know if the user need to get to hebrew or english site...
what i'm antissipating is that google because of it's IP will not be able to scan my hebrew version
what is the right way to use both a geolocation code and allow google to visit me :-)
here is my code:
<?php
if ($_GET["Lang"] == "he" || $_SESSION['ForceLang'] == "he") {
session_start();
$_SESSION['ForceLang'] = "he";
}
else {
require_once(realpath(".") . '/geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
if ($geoplugin->countryCode == "IL") {
开发者_运维问答 session_start();
$_SESSION['ForceLang'] = "he";
}
}
if ($_SESSION['ForceLang'] == "he") {
Header("Location: http://www.domain.com/he/");
}
?>
Google does not keep cookies, so tracking language with a session will not work for google or other robots.
That means you will want to work the language into the URL. Probably something like www.mysite.com/he/path/to/page. You could use rewrites so that the language code is simply return as a get variable.
You could also configure a separate domain name for other regions as well and select language based on that domain.
You will have to maintain that language code on all of your site links.
精彩评论