How to create multiple websites in Magento 2?

This article will help you to understand how one can add multiple websites in Magento 2.

Magento allows you to setup multi-websites on just single installation of Magento. Its configuration is really simple. It will allow you to create a separate website so you can handle the products, customers, product price and many more things on websites bases. 

After installing Magento you need to login into the store and follow the steps given below:

Step 1

Navigate to Stores>Settings>All Stores and create a new website, a new store and a new store view. 

This is just the sample data. For instance, we have named our website a German website. After saving this information you will find it in the list as shown below.

Step 2

Navigate to Stores>Configuration>General>Web>Base Urls, here you need to update the Base Url and Base link URL fields.

Navigate to Stores>Configuration>General>Web>Base Urls (Secure), here you will see that the Base Url and Base link URL fields will be automatically filled.

This image shows the base url section with the required domain name.

Step 3

We need to update these URLs for the german website. You will see a store view option at the top of the page on the left side. Open this drop-down menu and select the german website.

Step 4

Save this configuration.

Step 5

Now we need to open the .htaccess file from our Magento root directory. And find IfModule mod_rewrite.c section. Add below lines of code in this section.

SetEnvIf Host* MAGE_RUN_CODE=german_website
SetEnvIf Host* MAGE_RUN_TYPE=website

Now we will be able to access both our websites.

  • Share :