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)

About Ricard Torres

Senior Front-end Software Engineer at Netcentric, from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> if you need to.