Don’t modify index.php in Magento for multi-store configs

unless you really, really have to.  I did some quick Googling on this and found that a number of places recommend making changes to index.php.

In my humble opinion it is better to leave the index.php file alone and configure your stores via SetEnv in your Apache config, as is noted in the Magento wiki.

For example

<VirtualHost *:80>
SetEnv MAGE_RUN_CODE msv
ServerName kps.loc
DocumentRoot /var/www/magento.loc/magento
CustomLog logs/magento.access_log varnishcombined
ErrorLog logs/magento.error_log
</VirtualHost>

<VirtualHost *:80>
SetEnv MAGE_RUN_CODE base
ServerName magento.loc
DocumentRoot /var/www/magento.loc/magento
CustomLog logs/magento.access_log varnishcombined
ErrorLog logs/magento.error_log
</VirtualHost>

No code changes required and upgrades won’t break your modifications.

That is all.

Related posts

One thought on “Don’t modify index.php in Magento for multi-store configs

  1. benmarks

    Similar for enabling developer mode (& PHP error display, of course):
    #enable error display for dev
    SetEnv MAGE_IS_DEVELOPER_MODE
    php_flag display_errors on
    “SetEnvIf” also comes in handy if there is no access to vhost config:
    SetEnvIf Remote_Addr 127.0.0.1 MAGE_IS_DEVELOPER_MODE

Leave a Comment