Latest news

[Fix It Series] Magento Error: Front Controller Reached 100 router Match Iterations

No comments

PROBLEM:

The site is going down several times a day after appearing the Magento error: “Front controller reached 100 router match iterations”. Once this happens, we can’t access to both admin and frontend. What we have left is just an error page.

how to fix Front Controller Reached 100 router Match Iterations error

CAUSES:

This error will be shown when Magento cannot find a proper route for a request. Your routers start making infinitive references for dispatching requests.

In general, it should be able to match a request with the router that handles requests. The exception is only triggered when Magento has failed to create routers, and then the error Front controller reached 100 router match iterations will be displayed.

DEBUG:

In app/code/core/Mage/Core/Controller/Varien/Front.php inside of the dispatch() function. The following code snippet will give you an idea:

while (!$request->isDispatched() && $i++<100) {

    foreach ($this->_routers as $router) {

        if ($router->match($this->getRequest())) {

            break;

        }

    }

}

Replace the code above 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;

        }

    }

}

The error log to be generated var/log/system.log.

Or you can also add the following debug code to app / code / core / Mage / Core / Controller / Varien / Front.php: Line 183:

if ($i>100) {

        file_put_contents('/tmp/debug.txt', Mage::getConfig()->getNode()->asNiceXml());

               Mage::throwException('Front controller reached 100 router match iterations');

 }

SOLUTIONS:

    • If you found the error at admin section, let’s change the admin url in app/etc/local.xml to fix the problem. Replace urltoadmin value with the URL you want and your new admin URL should be: http://mymagentosite.com/urltoadmin
<admin>

    <routers>

        <adminhtml>

            <args>

                <frontName><![CDATA[urltoadmin]]></frontName>

            </args>

        </adminhtml>

    </routers>

</admin>
  • CMS module disabled: As you might know, the CMS module handles 404 not found requests which is the fallback router. Therefore, no router may be found in case this module is disabled.  Just enable the CMS module and check if the issue is solved.
  • Cache is corrupted: This is another common cause – Magento cache corrupted. In this case, the list of routers never get loaded because it loads from cache and the corrupted cache does not contain this data. Consequently, fully flushing the Magento cache will resolve thi issue. You can also delete /var/ cache folder to remove cache corruption.

Other possible solutions:

When upgrading or moving Magento, some cases went wrong:  Front controller reached 100 router match iterations.

You can easily fix this error by going to the SQL and running the following command:

SET FOREIGN_KEY_CHECKS=0; UPDATE `core_store` SET store_id =0 WHERE code='admin'; UPDATE `core_store_group` SET group_id =0 WHERE name='Default'; UPDATE `core_website` SET website_id =0 WHERE code='admin'; UPDATE `customer_group` SET customer_group_id =0 WHERE customer_group_code='NOT LOGGED IN'; SET FOREIGN_KEY_CHECKS=1;
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...
April Lee[Fix It Series] Magento Error: Front Controller Reached 100 router Match Iterations

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *