{"id":319,"date":"2020-11-19T06:20:03","date_gmt":"2020-11-19T06:20:03","guid":{"rendered":"http:\/\/www.evermoretechnologies.com\/blog\/?p=319"},"modified":"2020-11-19T06:20:03","modified_gmt":"2020-11-19T06:20:03","slug":"apache-2-config-for-magento-multisite","status":"publish","type":"post","link":"https:\/\/www.evermoretechnologies.com\/blog\/2020\/11\/apache-2-config-for-magento-multisite\/","title":{"rendered":"Apache 2 config for Magento Multisite"},"content":{"rendered":"<p>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.\u00a0 Nginx is the best production server web server, but Apache can serve as a good local development server.\u00a0 The Apache setup is simple, you just need to set the mage variables in the apache vhost config file.\u00a0 Here&#8217;s an example of a local vhost file I use.\u00a0 ecomm.local is the main store, so I don&#8217;t bother setting the MAGE_RUN_CODE variable.\u00a0 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.\u00a0 In this case, the proper store urls are already set in the admin.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;VirtualHost *:80&gt;\r\n        ServerName ecomm.local\r\n        DocumentRoot \/var\/www\/ecomm\/httpdocs\/pub\r\n\r\n        &lt;Directory \"\/var\/www\/ecomm\/httpdocs\/pub\"&gt;\r\n                Order allow,deny\r\n                AllowOverride All\r\n                Allow from all\r\n                Require all granted\r\n        &lt;\/Directory&gt;\r\n&lt;\/VirtualHost&gt;\r\n\r\n&lt;VirtualHost *:80&gt;\r\n        ServerName mcv.local\r\n        DocumentRoot \/var\/www\/ecomm\/httpdocs\/pub\r\n        SetEnv MAGE_RUN_CODE \"mcv\"\r\n        SetEnv MAGE_RUN_TYPE \"website\"\r\n\r\n        &lt;Directory \"\/var\/www\/ecomm\/httpdocs\/pub\"&gt;\r\n                Order allow,deny\r\n                AllowOverride All\r\n                Allow from all\r\n                Require all granted\r\n        &lt;\/Directory&gt;\r\n&lt;\/VirtualHost&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0&#8230; <a href=\"https:\/\/www.evermoretechnologies.com\/blog\/2020\/11\/apache-2-config-for-magento-multisite\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[34,13],"tags":[],"_links":{"self":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/319"}],"collection":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":1,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions\/320"}],"wp:attachment":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}