0

I want to overload the noRouteAction() to search for products based on the url and if found, redirect there. Else I want to use the default 404 page. Here is what I have: (for magento 1.8)

app/etc/modules/ACME_ErrorHandler.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <ACME_ErrorHandler>
            <active>true</active>
            <codePool>local</codePool>
        </ACME_ErrorHandler>
    </modules>
</config>

app/code/local/ACME/ErrorHandler/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <ACME_ErrorHandler>
            <version>1.0.2</version>
            <depends>
                <Mage_Page />
            </depends>
        </ACME_ErrorHandler>
    </modules>

    <frontend>
        <routers>
            <SkuRoute>
                <use>standard</use>
                <args>
                    <module>ACME_ErrorHandler</module>
                    <frontName>ErrorHandler</frontName>
                </args>
            </SkuRoute>
        </routers>
    </frontend>

    <global>
        <routers>
            <cms>
                <rewrite>
                    <index>
                        <to>ACME_ErrorHandler/index</to>
                        <override_actions>true</override_actions>
                        <actions>
                            <noroute><to>ACME_ErrorHandler/index/noroute</to></noroute>
                        </actions>
                    </index>
                </rewrite>
            </cms>
        </routers>
    </global>


</config>

app/code/local/ACME/ErrorHandler/controllers/IndexController.php

<?php
class WellLinked_ErrorHandler_IndexController extends Mage_Cms_IndexController
{
    public function noRouteAction($coreRoute = null)
    {
        header("X-Custom-Mod: working");
        parent::noRouteAction($coreRoute);

    }
}

The Problem is, it doesn't work! When the Module is activated, every nonexisting URL gives this error:

a:5:{i:0;s:52:"Front controller reached 100 router match iterations";i:1;s:377:"#0 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(179): Mage::throwException('Front controlle...')
#1 /var/www/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#2 /var/www/magento/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#3 /var/www/magento/index.php(126): Mage::run('default', 'store')
#4 {main}";s:3:"url";s:38:"/no-such-url";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

What did I do wrong?

1

You can use the default no route URL instead rewriting; Set the URL of your new controller Action in : System -> Configuration -> General -> Web -> Default Pages -> CMS No Route page

Hope that can help.

  • How would I then show the default 404 page when my module cannot find the requested page? – Josef Apr 9 '14 at 15:28
  • With a redirect function in your controller action : $this->_redirect('cms/index/noRoute'); – Ayoub Allali Apr 9 '14 at 15:32
0

There are issue in Config.xml

Here the code is 1.0.2 /errorhandler/index/noroute/

      <frontend>
        <routers>
            <skuroute>
                <use>standard</use>
                <args>
                    <module>ACME_ErrorHandler</module>
                    <frontName>errorhandler</frontName>
                </args>
            </skuroute>
        </routers>
    </frontend>
   </config>

And Class name of Controller is wrong

<?php
require_once Mage::getModuleDir('controllers', 'Mage_Cms').DS.'IndexController.php';
class ACME_ErrorHandler_IndexController extends Mage_Cms_IndexController
{

Most of import match route is exist Please checked at http://magentosupport.help/knowledgebase/solved-front-controller-reached-100-router-match-iterations/

  • I made the changes, but it still has the same problem. Or did you mean I have to delete the <global>...</global> part in the config.xml? If I do that, no error but the code is also not called – Josef Apr 10 '14 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.