Forward to wrong magento store

58 Views Asked by At

This is my code in the index.php of Magento to switch the Store:

if ($url['host'] === 'five-oaks-int.eu') {
    if ($geoplugin->countryCode === 'CH') {
        header('Location: http://schweiz.five-oaks-int.eu');
        exit;
    }

    Mage::run('five_oaks_german', 'store' );
} else {
    Mage::run('default', 'store');
}

If i call the url five-oaks-int.eu magento loads not the store five_oaks_german but the default store. The url in browser change to url of the default store.

Why shows magento not call the five_oaks_german? The store settings the url seems to be correct.

1

There are 1 best solutions below

0
Paul On BEST ANSWER

Can you post the output of $url?

The best way of doing this though is to use the MAGE_RUN_CODE and set it in the vhost (if you're using Apache) or use 'map' if you're using Nginx.

In Apache you can do this using .htaccess if you don't have access to the vhost:

SetEnvIf Host .*five-oaks-int.eu.* MAGE_RUN_CODE=five_oaks_german

Taken from: http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_apache.html

If you're on Nginx then you can use the 'map' - see http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_nginx.html