Have Magento respond to several domains with the same store

Have Magento respond to several domains with the same store

September 29, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Have Magento respond to several domains with the same store

Serving the Same Magento Store from Multiple Domains

As a senior developer and technical blogger working for Laravel Company, I often receive queries about complex setups like serving the same Magento store from multiple domains. This post will guide you through the process of achieving this.

Understanding the Requirement

The primary challenge here is to make your Magento installation respond with the same catalog, customers, and prices for two different domains—a.mydomain.com and b.anotherdomain.com. The key distinction lies in base URLs: when accessing via a.mydomain.com, all links should use this as the base URL, while b.anotherdomain.com should use its own.

Configuring Multiple Base URLs

Magento allows you to configure multiple base URLs for a single store. Here’s how to do it:

  1. Log in to your Magento admin panel.

  2. Navigate to Stores > Configuration.

  3. In the left-hand menu, select General > Web.

    Web Configuration

  4. Under the Unsecure Base URL, enter your primary domain (e.g., http://a.mydomain.com).

  5. Click Save Config.

  6. Scroll down to the Secure Base URL section and repeat step 3 for your second domain.

  7. Again, click Save Config.

    Multiple Base URLs

Adjusting Magento’s Behavior

By default, when you run a store in multiple base URLs mode, Magento will create separate database tables for each URL. To ensure the same data is shared across all domains:

  1. Open your terminal or command line.

  2. Navigate to your project’s root directory.

    cd /path/to/your/magento/project
    
  3. Execute the following PHP commands to reset Magento’s database:

    php bin/magento setup:uninstall
    php bin/magento setup:install --base-url=http://a.mydomain.com --db-name={DB_NAME} --db-user={DB_USER} --db-password={DB_PASSWORD}
    
  4. Replace {DB_NAME}, {DB_USER}, and {DB_PASSWORD} with your actual database credentials.

  5. After running these commands, Magento will reconfigure its database setup to share data across both domains.

Verifying the Setup

To confirm that everything is working correctly:

  1. Visit both a.mydomain.com and b.anotherdomain.com.
  2. Check if the URLs generated by Magento match their respective base URL.
  3. Perform a test checkout or add products to cart on one domain and verify they are reflected on the other.

Conclusion

Serving the same Magento store from multiple domains is achievable with careful configuration of base URLs in the admin panel and a reset of the database setup. This approach ensures that your customers, catalog, and prices remain consistent across all domains.

Remember to always keep your Magento instance up-to-date for the best security and performance practices. You can find more detailed guides on Laravel Company’s blog, including best practices for multi-domain setups and Magento optimization tips.

Happy coding!

Catalog Database Admin Configuration

Our network