Magento 1.9 – How to Get Previous URL and Redirect from Controller

ce-1.9.0.1controllersmagento-1.9redirecturl

How can I detect the URL and store it then use it on the Controller for Redirect. Can anyone help me with this?

Best Answer

To get current URL in Magento use below code.

$currentUrl = Mage::helper('core/url')->getCurrentUrl()

But i think your requirement is to get the previous URL & redirect from controller. If it so use below code.

$this->_redirectReferer()