When switching to another store view in the Magento front end, Magento responds only by redirecting back to the main store view domainstoreview1.tld/en_GB. The site worked ok with all the store views on one domain until I configured a different domain.tld for each store view in the Magento 2.3.2 admin panel.

Also, when typing in domainstoreview2.tld, Magento redirects to domainstoreview1.tld.

Remarkable, when you generate a site map, store views keeps using the maindomain.tld for several store views. For sure these store views all have their own domain.tld in the base url settings. After putting this within the .htaccess, the store view works when you type in storeviewdomain.tld, you have the right store view content:

SetEnvIf Host ^(.*)storeviewdomain1\.eu MAGE_RUN_CODE=en_GB
SetEnvIf Host ^(.*)storeviewdomain1\.eu MAGE_RUN_TYPE=store
SetEnvIf Host ^(.*)storeviewdomain2\.de MAGE_RUN_CODE=de_DE
SetEnvIf Host ^(.*)storeviewdomain2\.de MAGE_RUN_TYPE=store

However the store view switcher in the front end still does not work, when the browsers is in storeviewdomain2.tld and switch the scope to storeviewdomain1.tld, Magento redirects to the home of storeviewdomain2.tld.

I also tried changing index.php with standard htaccess and this index.php with above htaccess: Magento 2 Multistore is not working with multi domain index.php content:

try {
    require __DIR__ . '/app/bootstrap.php';
} catch (\Exception $e) {
    echo <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
    <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
        <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
        Autoload error</h3>

$params = $_SERVER;

switch($_SERVER['HTTP_HOST']) {

        case 'storeviewdomain1.eu':
        case 'www.storeviewdomain1.eu':
             $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'en_GB';
                         $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';

        case 'storeviewdomain2.de':
        case 'www.storeviewdomain2.de':
             $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'de_DE';
                         $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
        case 'storeviewdomain3.es':
        case 'www.storeviewdomain3.es':
             $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'es_ES';

                         $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\Framework\App\Http');

I did not edited my nginx virtual hosts file like stated in https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_nginx.html

etc/hosts file content:

ip1.add.res.ss1 storeviewdomain1.eu storeviewdomain2.de storeviewdomain3.es

After configuring different domains for each store view, Magento was recompiled, deleted all cache, switched browser and I hard reloaded the site to avoid any local cache issues. Magento 2.3.2 runs on Centos7 using nginx and varnish.

Your Answer

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

Browse other questions tagged or ask your own question.