How to Setup Multi Store in Magento 2
With a big catalog of 224+ extensions for your online store
Setting up Magento Multi Store is one of the variable functionalities Magento 2 brings to store owners. This feature allows you to create stores as many as you need only in a single configuration. All stores share the same domain, be set up as subdomains of the same domain, or have an entirely different domain, yet possibly share the same backend for easier administration.
Learn more: Setup automatic change store view using Magento 2 Store Switcher
Benefits of creating multiple stores in Magento 2
With different goals in mind, such as expanding your business or operating your business in different locations, you may want to create multiple stores. But multiple stores can bring you more amazing outcomes than that, such as:
- Save money by using the same payment gateways
- Get uniform support for all of your built stores from third-party extensions
- Maintain a standard customer database that may be used across all stores.
- Share the same content of Terms & conditions, privacy policy, and other materials for the pages.
Therefore, you can follow the instructions below to apply these awesome benefits to your store. Additionally, you can add multiple websites for each store you want to configure.
7 Steps to Setup Multiple Stores in Magento 2
- Step 1: Create Websites
- Step 2: Create Stores
- Step 3: Add Store Views
- Step 4: Setup the Website’s Base URL
- Step 5: Add the store code to the base URL
- Step 6: Change the base URL in the default store view
- Step 7: Server-side configurations
Step 1: Create Websites
Go to Store > Settings > All Stores
. Then, click on Create Website
, and fill out the following fields:
- Name: Insert a name for your new website.
- Code: This code needs to be unique.
- Sort Order (Optional): Insert the sort order for your website. Remember, the default is ‘0’.
Step 2: Create Stores
In this step, you will fill in the required information about the new store in the ‘Store Information’ section.
- On the Admin Panel,
Stores > Settings > All Stores
. - Click on
Create Store
, then follow the below- Select the
Website
that is the parent of the new store. If there is only one website, use the default “Main Website”. - Fill in the
Name
for the new store, just for internal reference. - In the
Root Category
field, you will set the root category for the main menu of the new store. The created root categories are shown in the dropdown list, select one for the store.
- Select the
Save Store
to complete.
Step 3: Add Store Views
After adding the new store, you will now need to create the store view:
- Click on
Create Store View
, you can:- Assign the
Store
to the new store you’ve just created. - Set the
Name
for the store view. - Type the
Code
for the store view with lower characters. - Choose “Enabled” for the
Status
. - Specify the
Sort Order
that is the position of the new store in the list.
- Assign the
Save Store View
to save all settings.
Step 4: Setup the Website’s Base URL
In this step, we will configure the Store URL.
- On the Admin Panel, go to
Stores > Settings > Configuration
. - On the left panel, under
General
, selectWeb
. - In the upper-left corner, choose
Store View
to check the new store you added. - Hit
OK
to verify the scope switching.
- Open the
Base URLs
section,- Clear the Use Website checkbox, that is next to the
Base URL
field. - Change the
Base URL
for the store.
- Clear the Use Website checkbox, that is next to the
- Open the
Secure Base URLs
section below to set the store’s secure URL if needed. Save Config
to complete.
Step 5: Add the store code to the base URL
With Magento, admins can add a store code to the website’s base URL, simplifying the multistore setup process. Thanks to this feature, store owners can cut down the step of creating directories on the file system for storing index.php and .htaccess.
Additionally, this option helps prevent index.php and .htaccess from falling out of sync with the Magento source in future upgrades.
- Go to the admin panel and navigate to
Stores > Settings > Configuration
. - Under the
General
section, chooseWeb
. - From the list at the top, select
Default Config
. - Then you will see the first section -
Url Options
, fill it out.
Step 6: Change the base URL in the default store view
- Navigate to
Stores > Settings > Configuration
. Under theGeneral
section, chooseWeb
. - From the list at the top, select
Default Config
. - Then, expand the
Base URLs
section and insert your website’s base URL. - Ex: https://www.example.com/
- Finally, click the
Save Config
button.
Note: You might be confused that your access to the admin panel is no longer active after this step. Don’t panic, it will be accessible again soon after you finish the next step - configuring virtual hosts.
Step 7: Server-side configurations
This is the final step to complete setting up Magento 2 multistore. At this point, store admins need to change a few things to the web server configuration. In detail:
- For each new website, create a new virtual host.
- Pass the MAGE_RUN_TYPE and MAGE_RUN_CODE values to the new configurations.
- Configure static routes to the host (Optional)
Depending on the type of server you run, the process of creating a new virtual host for your new websites may differ.
Ex: With Apache 2.4 and above servers, the process requires modifying your /etc/httpd/conf/httpd.conf likethis:
<VirtualHost *:80>
ServerName mysite.mg
DocumentRoot /var/www/html/magento2/pub/
</VirtualHost>
<VirtualHost *:80>
ServerName french.mysite.mg
DocumentRoot /var/www/html/magento2/pub/
SetEnv MAGE_RUN_CODE "french"
SetEnv MAGE_RUN_TYPE "website"
</VirtualHost>
<VirtualHost *:80>
ServerName german.mysite.mg
DocumentRoot /var/www/html/magento2/pub/
SetEnv MAGE_RUN_CODE "german"
SetEnv MAGE_RUN_TYPE "website"
</VirtualHost>
- ServerName: your new website’s domain.
- DocumentRoot: where Magento is enabled. It’s highly recommended to set DocumentRoot to Magento /pub/ directory for better security.
- SetEnv MAGE_RUN_TYPE: set to website or store, based on the ServerName: a new website/ a new store scope.
- SetEnv MAGE_RUN_CODE: configure to the unique website/ store view code corresponding to MAGE_RUN_TYPE.
After that, restart the web server by running:
- CentOS: service httpd restart
- Ubuntu: service apache2 restart
Configure static routes to the host (Optional)
If you don’t have DNS configured for your store’s URLs, create static routes in the hosts file, following this format:
<ip address> <new website>
Note: If you want a separate checkout procedure, configure your Magento domains to use different IP addresses. That’s it! Your multi-stores are now ready.
The bottom line
The need to set up Magento multi store has been increasing due to different business goals, and also because of the amazing benefits it can bring to online stores. If you also want to do it, start following this tutorial. Leave comments below to share your ideas and tell us about your concerns if any. See you in later posts!
Related Post
Looking for
Customization & Development Services?
8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.
Get free consultantRecent Tutorials

Change Store Email Addresses

Fix Magento 2 'Invalid Form Key. Please refresh the page'

Magento 2 Search Settings: Default Magento vs Mageplaza AJAX Search
Explore Our Products:
People also searched for
- magento 2 multistore
- magento 2 create store
- set default store view magento 2
- magento 2 multistore setup
- create multi store in magento 2
- magento 2 create new store
- magento 2 multi store setup
- magento 2 change default store view
- multi store in magento 2
- multistore magento 2
- create store view in magento 2
- magento 2 create store view
- in magento 2
- multiple store creation is not possible.
- magento 2 multi store subdomain
- magento multi store setup
- magento multi store
- magento 2 set default store
- magento 2 multiple stores
- magento 2 setup multiple stores
- magento 2 multiple stores different domains
- magento 2 set default store view
- magento 2 multi website multi domain
- magento 2 switch store programmatically
- magento multiple stores
- magento multi-store
- magento multi-shop
- magento multistore
- magento multiple stores different domains
- magento multi store demo
- magento multiple store
- magento default store
- 2.2.x, 2.3.x, 2.4.x
Stay in the know
Get special offers on the latest news from Mageplaza.
Earn $10 in reward now!