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 Magento 2 Multistore

Updated on December 23, 2021

4 Min Read

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.

Optimize Magento Speed Like a Pro

Subscribe now and get a free ebook to your inbox.

Thank You

Your Ebook is on it’s Way to Your Inbox.

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

Customer Review at

“Great speed, features, knowledgebase, dashboard, UX and fast, expert support. Very happy!”

Stefan [Management Consultant]

Fayyaz Khattak

Fayyaz, a passionate Motorbike tourist, works as a Team Lead — Magento Community at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. You can contact him at [email protected]


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

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Unleash The Cloud.
Not Budgets.

For 4 Months +
Up To 30 Free Migrations

Cyber Week

Time Left In Offer
  • 0


  • 0


  • 0


  • 0


40% OFF

On All Plans