Do not set a default MAGE_RUN_CODE for easier migration/deployment
We just deployed a site on the hypernode platform and noticed we got a 404 in the default Magento template on every url. Turns out we have a non-default store (view) code, meaning there was a mismatch between Byte's default "default" and our store code. This lead to Magento routing every request to a non-existing store, which leads to 404's.
I would propose that you don't set any MAGERUNCODE by default at all and let Magento decide to route the request to which store. Magento does not expect MAGERUNCODE to be set, except for the purpose of a multi website or store config.
Not setting this env var will lead to a looser coupling between the application and the hosting environment, which is always good. It will also be more consistent with other hosting environment, allowing for easier deployments.
Fixed (a while ago) with release http://support.hypernode.com/changelog/release-410-properly-set-mage_run_type-and-mage_run_code/
-
http://support.hypernode.com/release-410-properly-set-mage_run_type-and-mage_run_code/
Yeah, we've had a string of difficult migrations from the Byte platform. These sites did not have a storeview named "default". So well, that cost many people a lot of time :)
So I've added tests to replicate that situation and indeed, a 404 on any url not configured as a base_url.
That is fixed now.
Of course, if you mess up index.php you are on your own ;)
-
Hey Luk,
Thanks for the input. We'll change this behaviour in the coming week.
Best,
Allard
-
Luk van den Borne commented
My supposition that Magento does not need MAGE_RUN_CODE to be set is supported by the code in index.php:
/* 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';Mage::run($mageRunCode, $mageRunType);