Fixing “Front controller reached 100 router match iterations”

Ever got the bug: “Front controller reached 100 router match iterations”? Solve it as follows:

1. You can get more information by going to Magento Core file app/code/core/Mage/Core/Controller/Varien/Front.php, find there lines:

while (!$request->isDispatched() && $i++<100) {
foreach ($this->_routers as $router) {
if ($router->match($this->getRequest())) {
break;
}
}
}

Replace with:

Mage::log('----Matching routers------------------------------');
Mage::log('Total ' . count($this->_routers) . ': ' . implode(', ', array_keys($this->_routers)));
while (!$request->isDispatched() && $i++<100) {
Mage::log('- Iteration ' . $i);
$requestData = array(
'path_info' => $request->getPathInfo(),
'module' => $request->getModuleName(),
'action' => $request->getActionName(),
'controller' => $request->getControllerName(),
'controller_module' => $request->getControllerModule(),
'route' => $request->getRouteName()
);

$st = '';
foreach ($requestData as $key => $val) {
$st .= "[{$key}={$val}]";
}
Mage::log('Request: ' . $st);
foreach ($this->_routers as $name => $router) {
if ($router->match($this->getRequest())) {
Mage::log('Matched by "' . $name . '" router, class ' . get_class($router));
break;
}
}
}

Possible solution solving “Front controller reached 100 router” bug

What happened in my case? I opened the var/log/system.log file and there was downtime between 5 and 6. So there was a blankage between 5 and 6. The last log holds on 05:10, than the site went out:

2014-12-03T05:09:59+00:00 DEBUG (7): ----Matching routers------------------------------
2014-12-03T05:09:59+00:00 DEBUG (7): Total 7: admin, standard, cms, blog, default
2014-12-03T05:09:59+00:00 DEBUG (7): - Iteration 1
2014-12-03T05:09:59+00:00 DEBUG (7): Request: [path_info=/admin/][module=][action=][controller=][controller_module=][route=]
2014-12-03T05:10:02+00:00 DEBUG (7): Matched by "admin" router, class Mage_Core_Controller_Varien_Router_Admin
2014-12-03T05:10:02+00:00 DEBUG (7): - Iteration 2
2014-12-03T05:10:02+00:00 DEBUG (7): Request: [path_info=/admin/][module=admin][action=login][controller=index][controller_module=Mage_Adminhtml][route=adminhtml]
2014-12-03T05:10:02+00:00 DEBUG (7): Matched by "admin" router, class Mage_Core_Controller_Varien_Router_Admin

So search for the last entry before the outage. In my case there was an admin route problem. I solved it by changing the admin url in app/etc/local.xml (so far, so good). I’ll keep you updated if the outage will come again.

Thanks to: http://stackoverflow.com/questions/6262129/magento-front-controller-reached-100-router-match-iterations-error