In the following example I try to set environment variables according to the incoming request’s ‘HTTP_HOST’ value.
The following example pertains to Magento Webshop software which offers a different Store view for every domain configured to land in the main store.
– Magento is been configured, apart from its default Store View, to offer 2 other different Store Views: view1 and view2
– In our example the following 3 URLs are landing in the same Magento site and here are the intended results:
http://www.mystore.com ==>> Default Store view
http://www.mystore1.com ==>> view1 Store View
http://www.mystore2.com ==>> view2 Store View
Set the following 2 Environment Variables in Magento Apache vhost as follows:
SetEnvIf Host ^(www.)?mystore1.com$ MAGE_RUN_TYPE=store SetEnvIf Host ^(www.)?mystore1.com$ MAGE_RUN_CODE=view1 SetEnvIf Host ^(www.)?mystore2.com$ MAGE_RUN_TYPE=store SetEnvIf Host ^(www.)?mystore2.com$ MAGE_RUN_CODE=view2
In this example, in order for Magento to direct the request to the appropriate Store View it is expected to configure these 2 Store Views in Magento Administration area beforehand. If both of the Environment Variables(MAGE_RUN_TYPE and MAGE_RUN_CODE) are not set then Magento reverts to the default Store View.