0

How to point multiple URLs to the same website on Magento 2? I have 2 urls, both of which should open the same website. I have tried adding a case in index.php which points to an existing website's code.

case 'abc.example.in':
     $mageRunCode = 'abc_web';
     $mageRunType = 'website';
     break;
case 'pqr.example.in':
     $mageRunCode = 'abc_web';
     $mageRunType = 'website';
     break;

In base link url of the website(abc_web) I have put https://abc.example.in. When I try opening https://pqr.example.com, it does open the website but in the url it shows https://abc.example.in. I want https://pqr.example.com. Is there a way to do this?

0
$params = $_SERVER;
$domain2store = array(
    'domain.at'=>'at',
    'domain.ch'=>'ch',
    'domain.es'=>'es'
    );
if(isset($domain2store[$_SERVER['HTTP_HOST']]))
    $storecode = $domain2store[$_SERVER['HTTP_HOST']];
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = isset($storecode) ? $storecode : '';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);

Thats how we made it.

| improve this answer | |
  • I think this is for redirecting to different stores in a multi store website. I want to point the two urls to a website which has only one store. – Gaurang Singhal Mar 28 at 12:31

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.