Magento Tutorials

How to Setup Magento 2 with Multiple Stores and Domains

magento-2-multiple-stores-domains

Multiple websites or stores in Magento 2

Magento allows you to set up and manage multiple instances of domains or stores in a single Magento backend. This guide will walk you through how to set up multiple websites, stores, and store views in Magento 2. There are several ways to do this but setting up through backend is the most convenient way.

Step 1: Create websites

  1. In your Magento backend, go to Stores > Settings All Stores.
    magento 2 all stores menu
  2. On the Stores page, click Create Website.
    Magento 2 create website

    • Name: Enter a name to identify the website.
    • Code: Enter a unique code; for example, if you have a French store, you can enter french
    • Sort Order: Enter an optional numerical sort order.
  3. Click Save Web Site.
  4. Repeat these tasks as many times as necessary to create your websites.

Step 2: Create stores

  1. In your Magento backend, go to Stores > SettingsAll Stores.
  2.  On the Stores page, click Create Store.
    Magento 2 create store

    • Web Site: Select the website with which to associate this store.
    • Name: Enter a name to identify the store.
    • Root Category: Select the root category for this store.On the Stores page, click Create Store.
  3. Click Save Store.
  4. Repeat these tasks as many times as necessary to create your stores.

Step 3: Create store views

  1. In your Magento backend, go to Stores > SettingsAll Stores.
  2. On the Stores page, click Create Store View.
    Magento 2 create store view

    • Store: Select the store with which to associate this store view.
    • Name: Enter a name to identify this store view.
    • Code: Enter a unique name to identify this store view.
    • Status: Select Enabled.
    • Sort Order: Enter an optional numerical sort order.
  3. Click Save Store View.
  4. Repeat these tasks as many times as necessary to create your store views.

Step 4: Change the website’s base URL

  1. In your Magento backend, go to Stores > SettingsConfiguration. Under General section, click Web.
  2. From the Store View list at the top of the page, select a website.
  3. Expand Base URLs section.
    Magento 2 base url
  4. Enter this website’s URL. For example: https://subdomain.example.com/
  5. Click Save Config.
  6. Repeat these tasks for other websites.

Step 5: Add the store code to the base URL

Magento gives you the option to add the store code to the site’s base URL, which simplifies the process of setting up multiple stores. Using this option, you don’t have to create directories on the Magento file system to store index.php and .htaccess.

This prevents index.php and .htaccess from getting out of sync with the Magento codebase in future upgrades.

  1. In your Magento backend, go to Stores > SettingsConfiguration. Under General section, click Web.
  2. From the Store View list at the top of the page, select Default Config.
  3. Expand Url Options section.
    Magento 2 url options
  4. Uncheck the Use system value box next to Add Store Code to Urls. Then set this to Yes.
  5. Click Save Config.
  6. If prompted, flush the Magento cache. (System > Cache Management).

Step 6: Change the default store view’s base URL

You must perform this step last because after it’s done, you’ll lose access to the Magento Admin; your access returns after you set up virtual hosts as discussed in the web-server-specific topics.

  1. In your Magento backend, go to Stores > SettingsConfiguration. Under General section, click Web.
  2. From the Store View list at the top of the page, select Default Config.
  3. Expand Base URLs section.
  4. Enter your website’s base URL. For example: https://www.example.com/
  5. Click Save Config.

Step 7: It’s done! You have successfully set up multiple websites and stores in Magento 2

Related post: How to Add and Configure Multi Language for your Magento Store



SEE MORE:



6 Comments

Dom

A knowledge craver who always strive to be wiser everyday.

    avatar
    5 Comment threads
    1 Thread replies
    0 Followers
     
    Most reacted comment
    Hottest comment thread
    6 Comment authors
    Tom DDomAdnan Khaliqprashanth nagpalManju Recent comment authors
      Subscribe  
    newest oldest most voted
    Notify of
    Samuel
    Guest

    Saved me a lot of time here, thanks for your simple and clear guide!

    Manju
    Guest
    Manju

    Your steps helped me too.. Thanks! a lot.

    prashanth nagpal
    Guest

    Hi Dom, I am not into tech but i want my team to do the same on magento one. I have two url’s (both are operated and managed separately) by the same person. I wanted to know if i can use both as one website where customers are redirected and products are uploaded as per geography, but at the same time the backend should be only a single operational panel? Hope i have been able to explain my question.
    http://www.mirrorwhite.com and http://www.mirrorwhite.in

    Adnan Khaliq
    Guest
    Adnan Khaliq

    This post is helpful but I think I thing is missing that what to do with domains and their hosting in Cpanel.

    Tom D
    Guest
    Tom D

    Hey, i really cant find the this ” you set up virtual hosts as discussed in the web-server-specific topics.”
    Can you post a link 🙂
    T