0

I just need a help from you people. I am trying to connect two Magento web applications with a single database. It was done successfully but the problem I am facing is with the base URL.

I have two Magento applications with single base URL. When I am trying to open both websites URLs it is redirecting to one URL because I have one Database with a single base URL. Can you people guide me on this issue?

  • Have you created two stores? – akgola Jun 7 '18 at 11:05
  • You create two domain and point it to a single Magetno2 database. Right? – Emipro Technologies Pvt. Ltd. Jun 7 '18 at 11:06
0

In Magento 2, Store Configuration page, you need to change Store View/Website for website A & B,

Then open Web tab there you need to add website A url & then change store view to B then set website B url.

For more information visit devdocs link: https://devdocs.magento.com/guides/v2.2/config-guide/multi-site/ms_websites.html

| improve this answer | |
0

By default, Magento redirects to the base URL so that's the reason why when you try to access the second Magento application, it gets redirected.

For this perfect scenario only, Magento has features like multiple websites with single Magento instance. Please create another website, store and store view from Magento admin panel and change the second website URL to the second new domain you purchased. You should also add few lines of code in the index.php file for this to work. Please refer to my index.php below:

$params = $_SERVER;
$domain2store = array(
'xyz.com'=>'base',
'www.xyz.com'=>'base',
'abc.com'=>'apple_website',
'www.abc.com'=>'apple_website',
);    
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] = 'website';

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

After all, please do a static content deployment and refresh the cache. You are set. I hope this helps.

| improve this answer | |

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.