We tried to upgrade our Magento installation from to Now we got the following error on all pages:

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

We tried to clear all caches, disable and recompile the compiler and reindex the indexer. Earlier today everything went well on our local installation. This is the same installation except some orders and client data.

When the compiler is enabled the error changes in:

Fatal error: Call to a member function rewrite() on a non-object in /home/clientname/domains/domain.com/public_html/includes/src/__default.php on line 17761

How we can debug this error?

  • I too upgraded to 1.8 magento Mine has some same problem but the error i am getting is not in the varien...see the error as below: > Fatal error: Call to a member function getProductAttribute() on a > non-object in > /home/shopk3if/public_html/app/design/frontend/base/default/template/catalog/product/price.phtml > on line 50 plz help me for the code as I'm not the developer...
    – user3391
    Commented Sep 28, 2013 at 15:17
  • Are you sure that you have compilation turned off? Commented Sep 28, 2013 at 21:46
  • @MichaelvanEijden Were you able to track down the root cause of this? Commented Sep 30, 2013 at 3:37
  • 1
    @AlanStorm For some reason, there was only a part of the files transfered during the upgrade. Your answer brought me to the right place though. Thanks!
    – Michael
    Commented Sep 30, 2013 at 6:30
  • I have the same issue..... but I now tried to overwrite all files with the contents of the magento ZIP installation archive.... but it didn´t help. That´s going to become a loooong debug session! NO update of Magento up to now worked for me without problems!
    – cljk
    Commented Nov 11, 2013 at 14:06

7 Answers 7


Looking at line 165

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

The method _getRequestRewriteController should return an object. For some reason, it's not returning an object in your system.

Taking a look at that method definition, we see the following

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

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

Mage looks at the global/request_rewrite/model configuration node to find a class alias. In a store system this should be


Which Magento then uses to instantiate a model. My two guesses are

  1. There's a module with a different, invalid class name here, which prevents Magento from instantiating the object.

  2. Your system is missing the Mage_Core_Model_Url_Rewrite_Request class file (at app/code/core/Mage/Core/Model/Url/Rewrite/Request.php), which is new in Magento 1.8

  • 1
    Also, see the answer/comments from @navotjer below. Commented Dec 12, 2013 at 23:10

I had the same issue, and beside clearing the cache, I had to set folder permissions on /var and subdirectories to 777 (don't worry, the .htaccess file in /var prevents everything to be "human" readable).

  • 1
    Ran into this today and seconding this answer — untaring a new Magento codebase can change the permissions on your var folder, which means Magneto may revert to a system var folder that has an old cached configuration. Commented Dec 12, 2013 at 23:10

If you have a cache server like memcached try to restart it as well. I had the same issue and I resolved this way.

  • 1
    Or if Redis: redis-cli flushall
    – kiatng
    Commented May 6, 2015 at 3:39

Clear redis cache;



Its solved problem.


I tried to follow the explanation by @AlanStorm, but ultimately found it was a caching issue. I just had to rm -rf * all the files in ~/public_html/var/cache and I found that the site loaded correctly.

  • Simple like this. I had the same problem when upgrading from 1.7 to 1.9, but forgot to clear cache folder. Commented Feb 17, 2015 at 13:16

I have the same issue

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

Deleting all in /var/cache solves the problem


Deleting everything in var/cache solved the problem for me as well.

Also had to delete the maintenance.flag file before this problem occurred, as a maintenance page was present.

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.