How to Redirect URL in Magento?

When the redirect goes into effect, any existing links that point to the previous URL are seamlessly redirected to the new address.Sometimes, you can create a new action in the controller, set phtml file as template for that new action, and redirect from your action to new action.The redirect functions are present in

* Redirect to certain url  */
_redirectUrl($url)

/* Redirect to certain path */
_redirect($path, $arguments=array())


/* Redirect to success page */
_redirectSuccess($defaultUrl)

/* Redirect to error page */
_redirectError($defaultUrl)

/* Set referer url for redirect in response */
_redirectReferer($defaultUrl=null)

_redirect() function make a "simple" redirect to the provided URL.

<?php
// $this->_redirect('module/controller/action');
$this->_redirect('customer/account/login');
?>

_redirectUrl() function which helps to redirect our action to external URL outside Magento base.

<?php
$this->_redirectUrl('customer/account/login');
// or
$this->_redirectUrl('http://domain.com');
?>

Also,you can use below mentioned code

<?php
$url=Mage::getUrl('*/*/placeOrder');

Mage::app()->getResponse()->setRedirect($url)->sendResponse();
// or
Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse();
?>

If you face any problems or need our professional services, please email us at [email protected]

Join our Newsletter

Never miss the latest offers, voucher codes and useful articles delivered weekly in your inbox.