0

I'm using Magento 1.8.0 with multiples websites for each country, for example

  1. USA (Website) with english (store views)
  2. France (website) with french and english (store views)
  3. 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.

  • Actually, I tried to do an url rewriting on my .httaccess, I want to first rewrite ch_fr to CH-fr. – CVL Jul 21 '15 at 7:36
0

I think a good approach to this would be to implement a router which servers before 404 error.

The router checks, where the customer is from and where to redirect. If this is possible you have a controller which does this.

If not you just skip the router and serve a 404 error.

  • It seems to be a good solution, I will try to investigate on that. – CVL Jul 21 '15 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.