0

I've faced the problem: my seo-specialist asked me to redirect all 404 to same url (/404.html). Not to show content on noRoute page but redirect to this url.

I've made changes in /app/code/core/Mage/Cms/controllers/IndexController.php:

/**
 * Render CMS 404 Not found page
 *
 * @param string $coreRoute
 */
public function noRouteAction($coreRoute = null)
{
    $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
    $this->getResponse()->setHeader('Status','404 File not found');

    $pageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_NO_ROUTE_PAGE);
    if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
        $this->_forward('defaultNoRoute');
    }
    $this->_redirect($pageId);
}

It works on local version but doesn't on live.

When I comment headers it works:

// $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
// $this->getResponse()->setHeader('Status','404 File not found');

But I think it's incorrect solution, please help me.

1 Answer 1

0

Rather then changing core module I would suggest you to look into

System > Configuration > Web > Default Pages > Default No-route URL

Here you can see that default no-route URL is cms/index/noRoute. So just change this from your module controller and do your changes. For example (YOUR_ROUTE/CONTROLLER NAME/ACTION NAME)

1
  • I've moved file to /app/code/local/Mage/Cms/controllers/IndexController.php but it doesn't seem to be overriden. I mean I can't override this file in usual way Commented Jan 26, 2018 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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