How to set a Store View via .htaccess Magento


You can set the Store View code adding the following line to your .htaccess

In this example my Store View code is "french":

SetEnv MAGE_RUN_CODE french

Hint: you can see your Store Views codes through your Admin > System > Manage Stores

How does it work?

In your index.php file in your root directory you will find the following lines (probably at the end of the file).

As you can see it uses the $_SERVER['MAGE_RUN_CODE'] if it has been set.

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';Code language: PHP (php)

Leave a Reply

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