I have a website with 2 store views and different domains assigned to them through System > Web > Unsecure/Secure > Base URL (default one with en code at http://tea-and-coffee.tk/ and additional with ru code at http://teaandcoffeeuk.tk/).

I can switch between them with default language switcher in header and everything works fine except one thing. When I go to incognito mode in my browser and open any page at ru store view like http://teaandcoffeeuk.tk/tea.html, it always redirects me to an index page of default store - http://tea-and-coffee.tk/.

After I manually switch to ru store view through language switcher, links start working fine, so my guess is that different stores require some cookies set in my browser. Can anybody help me?


After doing some research I've managed to solve it with adding the following code to index.php just before Mage::run($mageRunCode, $mageRunType);

switch ($_SERVER['HTTP_HOST']) {
    case 'tea-and-coffee.tk':
        $mageRunCode = 'en';
        $mageRunType = 'store';
    case 'teaandcoffeeuk.tk':
        $mageRunCode = 'ru';
        $mageRunType = 'store';
        $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
        $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

This way magento resolves required store by hostname automatically. Everything is working flawlessly so far.

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.