I'm using Magento 1.8.0 with multiples websites for each country, for example
- USA (Website) with english (store views)
- France (website) with french and english (store views)
- Switzerland (website) with french, german and english (store views)
Actually, when someone visit my website, I use a geoIP script to redirect it to the right store views.
$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=184.172.117.120') );
//Get country code
$code = $geoPlugin_array['geoplugin_countryCode'];
//Get browser Language
$browserLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$browserLanguage = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if ($code == "CH") {
switch ($browserLanguage){
case "fr":
$mageRunCode = "ch_fr";
break;
case "de":
$mageRunCode = "ch_de";
break;
default:
$mageRunCode = "ch_en";
break;
}
}
I choose to add the store views to the URL, because my store are SEO friendly (I think). ch_fr, ch_de, ch_en, us_en...
So my website will look like : www.mystore.com/ch_fr/
This work fine it the user goes to the homepage, but If I want to share a link to a specifc produc on Facebook for example, I can't. For example :
I have a product, www.mystore.com/us_en/category-in-english/myProduct.html But in Swiss-french, it should be : www.mystore.com/ch_fr/categorie-en-francais/monProduit.html
Ideally, I would like to share a link like : www.mystore.com/myProduct.html and to be redirect by the same geoIp to the right country/language.