I have one Magento 2 install on the first domain www.domain1.com and have created a website in the store admin for the second website www.domain2.com as well as changing the URL for the new site in configuration > Web > General.

The domain2 is setup in cpanel as an alias to /index.php

I have added code to the index.php site as per:

$params = $_SERVER;
$customstore = array(
    'www.domain1.com'=>'base', // Website, Store or Storeview Code
    'www.domain2.com.au'=>'web2'     // Website, Store or Storeview Code
    $websitecode = $customstore[$_SERVER['HTTP_HOST']];
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = isset($websitecode) ? $websitecode : '';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';//use website or store or view 
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');

I think all I am getting is a redirect to the base site as the domain changes to domain1.com

What have I missed?


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.