How to test multiple websites in Magento 2

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

  1. Build a new file index2.php in root folder
  2. Include this code

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>







$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');

  1. 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’;

  1. Enter you Magento site
  • Enter your Magento site with URL:
  • Reference:






Leave a Reply

Your email address will not be published. Required fields are marked *