I have migrated a Magento 1 shop to Magento 2. All is working as expected except for the multi website setup. My original M1 installation consisted of 1 website with 2 stores (different domains: .nl and.be), both of them had 2 storeviews (different languages NL and EN, NL and FR). All documentation I can find is showing how to setup the websites and stores in Magento2 and what to alter in index.php to get the wanted result on frontend. My problem is that all this documentation provides solutions for showing multiple websites, but my setup consists of 1 website and therefore one website-code (‘base’). Also it doesn’t explain how the second domain needs to be set up, what do I put in the index-file there? I figure I need to use the store-code instead but I can’t get the second domain to work. The main domain is working (because that’s ‘base’).

enter image description here

Here’s what I’ve tried so far:

  • I have setup the second domain and created symlinks to the main folder for app, var, pub and lib.
  • Edited index.php in the root of my website in various ways. Below is just one example of many I tried, I’m showing this one because in my head it should be something like this.
    $params = $_SERVER;
    
    switch($_SERVER['HTTP_HOST']) {
             case 'spijl-in-stijl.be':
             case 'www.spijl-in-stijl.be':
                  $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'spijl-in-stijlbe';
                  $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
             break;
             default:
                  $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'base';
                  $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
    }
    
    • Created and edited index.php in my second domain folder. It’s either showing 403 forbidden or it’s redirecting me to the main domain.
    • Tried using store-codes in stead of websitecodes but it’s throwing errors (can’t find the requested store)
    • Tried editing the storeviews on backend by changing the second store setup, it broke the entire website, could only restore it by editing base URL’s in the database.
    • Edited .htaccess in root, added an edited .htaccess in second domain

    The settings in backend are set properly. All base URL’s are set correctly. It all comes down to the same theory> It would probably work if the website code was different for both domains.

    I’m really hoping someone can help me with this.