Magento Enterprise 1.9.0.0 redirects to home page instead of 404 error page

If you have installed and working on latest Magento’s Enterprise Edition 1.9.0.0, you could find some strange behavior with 404 error page and landing page. People say there is a patch for this, but I would like to present a quick fix for those of you who need an urgent solution. Issue is that you’ll get status 200 OK for each non-existing CMS page or controller and you will be redirected to home page.

Bug is in class Mage_Core_Controller_Varien_Router_Default, at line 42. Do not edit this core file, since it’s Magento Enterprise Edition!
Solution is to:

  • create folders “MageCoreControllerVarienRouter” in yours “appcodelocal” folder
  • copy source file “Default.php” from “appcodecoreMageCoreControllerVarienRouter” into your local folder
  • update the line 42:
$actionName = isset($noRoute[1]) ? $noRoute[1] : 'index';

– and replace with:

$actionName = isset($noRoute[2]) ? $noRoute[2] : 'index';

Enjoy coding.