Configure multiple domain names on apache2

Good question. I might do video on this… one day.

So, it seems like you have already done most of the heavy lifting :+1:

I’ve not tested this in Magento 2, but I’m pretty sure it would work this way:

Example of Stores Setup


Example of Apache Config File 1 (Port 80)

<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName exampleone.com
    SetEnv MAGE_RUN_TYPE "exampleone"
    SetEnv MAGE_RUN_CODE "english"
</VirtualHost>

Example of Apache Config File 2 (Port 80)

<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName exampletwo.com
    SetEnv MAGE_RUN_TYPE "exampletwo"
    SetEnv MAGE_RUN_CODE "english"
</VirtualHost>

Therefore, Apache would check what URL the visiting was trying to access (exampleone.com or exampletwo.com)… Then reroute the connection to the specific Web Site / Store View

Magento Official Documentation:

  • MAGE_RUN_TYPE can be either store or website
    • Use website to load a website in your storefront.
    • Use store to load any store view in your storefront.
  • MAGE_RUN_CODE is the unique website or store view code that corresponds to MAGE_RUN_TYPE

If it doesn’t work, it’ll be a few days before I get a chance to try this myself. Let us know how you get on.

1 Like