If you have multiple website and you need to test them on your development environment. How do you do that?
In case multiple store, Magento 2 permit you to test the stores through nav bar on header or footer. But nothing for multiple websites
To do that, you can follow the below steps:
Step 1: Build a new file index2.php in root folder
Step 2: Include this code
Step 3: Modify this code with your case
Step 4: Enter you Magento site
- Build a new file index2.php in root folder
- Include this code
<?php 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> </div> <p>{$e->getMessage()}</p> </div> HTML; exit(1); } $params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '<code>'; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = '{store|website}'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app);
- Modify this code with your case
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = ‘<code>’;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = ‘{store|website}’;
- Example:
You have website with code = website_a
- Let change code:
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = ‘website_a’;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = ‘website’;
- Enter you Magento site
- Enter your Magento site with URL: http://magento2.com/index2.php
- Reference: http://devdocs.magento.com/guides/v2.1/config-guide/multi-site/ms_over.html
- http://devdocs.magento.com/guides/v2.1/config-guide/multi-site/ms_apache.html
Leave a Reply