Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

How To Create & Configure Multi Store In Magento 2

January 18, 2016

4 Min Read
Reading Time: 4 minutes

Magento is an incredibly powerful ecommerce software that is the most preferred amongst ecommerce store owners. Recently, Magento 2 was launched with new features. One of the features for developers and merchants is the Magento 2 multistore function.

How To Create and Configure Multi Store In Magento 2

We can setup Magento 2 multistore like we did in Magento 1, however, as we know Magento 2 is totally different with Magento 1 and is a bit difficult to get along for those peoples who recently started development in Magento 2 because of the change in the file system.

In this article, I am going to show you how to configure Magento 2 multistore.

Scalable Hosting to Launch & Manage Magento Multistores

With Cloudways you can manage all your Magento multistores from a single dashboard. And, if you get short on space, scale it with just a single click.

Create Second Store:  

For creating Magento 2 second store, go to your Magento 2 admin dashboard and then go Stores/ Settings / All Stores

magento 2 admin panel

  • Under  “All Stores”  you can see three options “Create Website”, “Create Store View”, “Create Store”. First click on Create Website Button.

                  Create Store magento 2
  • In the name field, enter your second store name
  • In code field, enter your second store code name (Be sure to remember your second store code)second store magento 2
  • Now click on Create Store for your second store website and those you created before. Click on “Create Store” option.Create Store magento 2
  • In “Web Site” option select your Magento 2 website
  • In “Name” field enter your Magento 2 store view name
  • In “Root Category” select “Default Category” and click on the “Save Store” button.multi store magento 2
  • After creating store now create store view for your Magento 2 second store. Click on “Create Store View”Create Store View magento 2
  • In “Store” field select your Magento 2 store
  • In “Name” field enter your Store View Name
  • In “Code” field enter code those you enter in “Create Website”Create Store View Magento 2
  • After this, click on “Save Store View” button. And now we connect our second store domain with new store that we have just created. Go to Stores > Settings > Configurationmultistore magento 2
  • Under “Configuration” select your second store in “Store View” option, the one you see on topmagento store configuration

Your store is now set-up successfully at the back-end of Magento 2. Now set values for MAGE_RUN_TYPE and MAGE_RUN_CODE by using the following code in your index.php entry point:

$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');

Save your index.php file. After this set values in .htaccess file. This section discusses to set values for MAGE_RUN_TYPE and MAGE_RUN_CODE for using Apache Server Variables SetEnvIf or RewriteCond.

For setting up SetEnvIf, add following code in your .htaccess file after “RewriteEngine on” this:

SetEnvIf Host .**
SetEnvIf Host .** MAGE_RUN_TYPE=website

For setting up RewriteCond, add following code in your .htaccess file after “RewriteBase /magento/” This:

RewriteCond %{HTTP_HOST} ^(.*)example\.com
RewriteRule .* – []
RewriteCond %{HTTP_HOST} ^(.*)example\.com
RewriteRule .* – [E=MAGE_RUN_TYPE:website

Save your .htaccess file.

Magento Managed Cloud Hosting

Your Magento 2 Multiple Store is now ready for deployment! You worked so hard to put it to work, why not host it on the most optimal performance oriented ecommerce hosting platform to ensure that your cart abandonment stays below the danger line. Come home to the best managed Magento hosting platform, Cloudways.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Boost Your Magento Store Performance by 5x Times & Maximize Your Sales

Our fastest Magento hosting can help you in growing your business revenue by 500%

Fayyaz Khattak

Fayyaz is a Magento Community Manager at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

BFCM 2019