Apache 2 config for Magento Multisite

      No Comments on Apache 2 config for Magento Multisite

In my opinion, the best way to handle Magento 2 multi site urls is to use the Nginx or Apache config to set the store code based on the URL.  Nginx is the best production server web server, but Apache can serve as a good local development server.  The Apache setup is simple, you just need to set the mage variables in the apache vhost config file.  Here’s an example of a local vhost file I use.  ecomm.local is the main store, so I don’t bother setting the MAGE_RUN_CODE variable.  mcv.local is the second site with a website code of mcv, so that domain sets the proper variables for loading the right site based on the url.  In this case, the proper store urls are already set in the admin.

<VirtualHost *:80>
        ServerName ecomm.local
        DocumentRoot /var/www/ecomm/httpdocs/pub

        <Directory "/var/www/ecomm/httpdocs/pub">
                Order allow,deny
                AllowOverride All
                Allow from all
                Require all granted
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerName mcv.local
        DocumentRoot /var/www/ecomm/httpdocs/pub
        SetEnv MAGE_RUN_CODE "mcv"
        SetEnv MAGE_RUN_TYPE "website"

        <Directory "/var/www/ecomm/httpdocs/pub">
                Order allow,deny
                AllowOverride All
                Allow from all
                Require all granted
        </Directory>
</VirtualHost>

 

Leave a Reply

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