All about Magento E-commerce Store.......MagentoForum: Magento redirect

Saturday, July 9, 2011

Magento redirect

Using redirection in Magento controllers is not a rocket science thanks to Mage_Core_Controller_Varien_Action::_redirect() and Mage_Core_Controller_Varien_Action::_redirectUrl() methods. When trying to create redirection in CMS page (to prevent not logged-in users from accessing it) I found follwing code very helpful:

 Mage::app()->getFrontController()            ->getResponse()            ->setRedirect('http://your-url.com');

The setRedirect() method accept two parameters – target URL and redirect code (302 by default).

No comments:

Post a Comment