Multi Website Domain Setup in Magento 2 using DDEV

Within just one single instance of Magento, we can have multiple websites, stores, and storeviews operating on the same Magento backend. This allows limitless flexibility for your eCommerce operations.

In today’s tutorial, We are going to see how we can do multiple domain setups for our Magento project in the DDEV Local environment.

DDEV is an open-source tool for launching local web development environments in minutes. It supports PHP, Node.js, and Python, etc languages.

While developing in the local environment, creating virtual hosts, adding hosts and many more configurations was time-consuming and complex.

But using DDEV you can add and link multiple domains with your Magento 2 projects in a few easy steps.

So, let’s start by following the below the quick steps.

Step 1: Add Additional Domain

To start with a multi-website setup you will be required to add a new domain to your ddev project for your second website.

Suppose, I have firstdomain.ddev.site as my main domain for the main website and I want to link a new domain to my second seconddomain.ddev.site domain.

I will need to define my second domain to the additional_hostnames inside the .ddev/config.yaml file.

So, to reflect changes we need to restart our project using the below command.

After restart, if you perform ddev describe, you will see the new domain added to the project followed by seconddomain.ddev.site

Step 2: Link the domain with the second website

Now, as our new domain is configured, we need to link it with our second website store.

To do this, you have to add the below code at the start of the .ddev/nginx_full/nginx-site.conf file

Note : you have to remove #ddev-generated line from this file in order to allow your customization.

Step 3: Restart the project to reflect nginx configurations

By following the above steps, you will be able to access your second store using seconddomain.ddev.site

If you like this tutorial, Please share it with your team members. 🙂

Don’t forget to check the below ddev related tutorials :

DDEV Docker: How to install additional PHP extensions in the DDEV project?

DDEV Docker: How to change the project PHP version?

DDEV Docker: Configure Cron in Magento 2

Comments

    1. Post
      Author

Leave a Reply

Your email address will not be published. Required fields are marked *