Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    Create multiple websites in Magento2 and access them with different domains

    In this blog we will be learning how to create multiple websites in Magento2 and access them with different domains.

    The magento2 provides a functionality in which you can configure different websites from same magento instance. In this blog, we will see how to do the same!

    We will be mapping two domains i.e. and

    1. Install the magento and configure the server normally for the main site

    2. Now, create a new website, store and store view under Admin > Stores > Settings > All Stores

    3. Go To Admin > Stores > Settings > Configuration > General > Web

    4. This is the most important step as not selecting the secondary store, you can loose the access to the admin panel of the site.

    Select secondary store from the store configuration at the top:

    5. Configure the Base Url and the secure Base Url according to and save the config.

    6. Now create a sub-directory(any name, lets say it secondary) at the root of the magento2 installation.

    7. Copy the index.php and the .htaccess files from the root of the Magento2 to the sub folder.

    8. Replace the code in index.php:


    And Code:


    9. Now comes the role of the server management. You need to map the domain to /directory of magento installation/subfolder which we just created

    In my case it is: /var/www/html/secondary

    10. Now you need to create symlinks inside the new folder(secondary) to allow the secondary site access the CSS files and other static content.

    Execute the following commands using the terminal in the secondary folder:

    ln -s /home/example/ app

    ln -s /home/example/ lib

    ln -s /home/example/ pub

    ln -s /home/example/ var

    11. Clear Magento cache, generated, deploy static content at the root of the magento installation and check the site at

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again