Set Magento website based on URL

When your Magento installation has multiple sites set up within it, you will probably want to change which site shows based on domain or subdomain URL.  You can do this via .htaccess or your httpd virtual hosts config.

In .htaccess you can do this

SetEnvIf Host mydomain\.uk MAGE_RUN_CODE=ukwebsitecode
SetEnvIf Host mydomain\.uk MAGE_RUN_TYPE=website

SetEnvIf Host mydomain\.eu MAGE_RUN_CODE=euwebsitecode
SetEnvIf Host mydomain\.eu MAGE_RUN_TYPE=website

Inside your virtual host setting you can use this syntax for each ServerName/URL:

<VirtualHost *:80>
DocumentRoot “c:\wamp\www\mysite”
SetEnv MAGE_RUN_CODE “ukwebsitecode”
SetEnv MAGE_RUN_TYPE “website”

The “ukwebsitecode”  or  “euwebsitecode” is the code set inside the “System > Manage Stores” area of the Magento admin.

Facebook Comments

Leave a Reply

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

Apply your human brain cells and complete this highly complicated maths problem *