9

In my admin controller action I want to redirect to the previous page. How can I do this?

27

Try this:

$this->_redirectReferer();

it does a little more than redirect to the previous page. If you specify in the url a parameter uenc it will consider that as the referrer.

  • Thanks it worked properly as I expected. And I went through the function where located in Mage_Core_Controller_Varien_Action. I think Mahmood Rehman's answer contains the development which has been done through this _redirectReferer() function. – Sukeshini Nov 1 '13 at 10:01
9

Try this code :

 Mage::app()->getResponse()->setRedirect($_SERVER['HTTP_REFERER']);
        Mage::app()->getResponse()->sendResponse();
            exit;
  • This worked perfectly. Thanks a lot. When you go through the Mage_Core_Controller_Varien_Action class you can find the _redirectReferer() function which has developed similar way as your answer. Thanks and +1 – Sukeshini Nov 1 '13 at 10:05

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.