My site is not loading, as I get this error message when type in the URL:

Fatal error: Call to a member function rewrite() on a non-object in app/code/core/Mage/Core/Controller/Varien/Front.php on line 165

Does any one familiar with what could be wrong here?

5 Answers 5


If you look at the file to which magento points out, you can find the below line which comes inside dispatch method

File : app/code/core/Mage/Core/Controller/Varien/Front.php


The error says rewrite() is calling on a non-object. This means that, $this->_getRequestRewriteController() provides you a non-object (most probably it returns an empty value).

Why $this->_getRequestRewriteController() gives you a non-object ? In order to find the reason, let us have a look on this method definition.

protected function _getRequestRewriteController()
    $className = (string)Mage::getConfig()->getNode('global/request_rewrite/model');

    return Mage::getSingleton('core/factory')->getModel($className, array(
        'routers' => $this->getRouters(),

The method just trying to create a model instance of $className. Here $className holds a value which is returned by $className = (string)Mage::getConfig()->getNode('global/request_rewrite/model');. The default value which return by this call is core/url_rewrite_request. This means the method _getRequestRewriteController() is supposed to return an instance of model class Mage_Core_Model_Url_Rewrite_Request by defalt.

Based on this analysis, the error may be caused due to

  1. You may have a wrong class name in the above specified node. app/code/core/Mage/Core/etc/config.xml is used to define this node value. Since it is a core file, alternation happens here may be a rare chance. There is a possibility of rewriting this node by any external plugins. So this should be validated first.

  2. Ultimately your magento application do not have the file which defines this class Mage_Core_Model_Url_Rewrite_Request which normally appers at app/code/core/Mage/Core/Model/Url/Rewrite/Request.php

  3. I have found out some threads, which gives a hint that permission problems on var/cache directory may also cause this weird issue.

Hope that helps.


I had exactly the same issue and I found that going into var/cache and deleting everything in there worked for me.


Just thought I'd share this with everyone: I got stuck in a situation like this. There was a problem with one of my mysql upgrade scripts and even though I had var folder and used apc.php to try and flush that cache out I was still hitting this problem. I finally got out of it by placing an apc_clear_cache ('user'); command at the beginning of my index.php file which then allowed me to work through the upgrade script problems of which I had three. I then put my index.php back to what it was.



I had the same issue, but i'm using redis, "flushall" from redis-cli did the trick


This issue generally occurs when we upgrade Magento version. By the way for any reason if you have this issue, then first of all you should do this:

Clear cache

rm -rf var/cache/*

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.