How can I redirect customers to external urls i.e. other websites from template and controller in magento 1.9? Like Mage::app()->getResponse()->setRedirect('https://payment.api.com'); exit;. It is not working for external urls in template.

  • Mage::app()->getResponse()->setRedirect() does work for internal and external URLs likewise, though this is something you want to put into your controller rather than a template. I think you need to be more specific with what issue you're experiencing and tell us how and where you did set up that redirect with some more actual code. Jan 20, 2018 at 18:23
  • @ChristophFarnleitner Some thing like redirecting to api .
    – P S
    Jan 20, 2018 at 19:04
  • Still you should share more than just an updated external URL in your question as suggested in my comment above already. there is way more context needed in order to figure out why your redirect is not working. Jan 20, 2018 at 19:37

3 Answers 3


Just add the another function sendResponse() to your code.

Mage::app()->getResponse()->setRedirect('https://payment.api.com') ->sendResponse();

then add return ;

Mage::app()->getResponse()->setRedirect('https://payment.api.com') ->sendResponse();

return ;

  • It's working. I don't know how. I had seen your solution in different question with exit; . Anyway thanks.
    – P S
    Jan 21, 2018 at 5:03

To redirect to an external url, use this function: _redirectUrl(). To redirect to another page within Magento, use this function: _redirect().

For Example: Mage::app()->getResponse()->_redirectUrl('https://www.yourwebsite.com');


That's maybe not the smartest solution but should work straight from template:

<script type="text/javascript">

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.