If you have multiple website and you want test them on your development enviroment. How do you do that?
In case multiple store, magento 2 allow you switch among stores via nav bar on header or footer. But nothing for multiple website.
To do that. You can follow steps:
Contents
Step 1: Create a new file index2.php in root folder.
Step 2: Add this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?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); |
Step 3: Change 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’;
Step 4: Enter your 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