Redirection in Zend Framework

Quite often you need to redirect to another controller/action after a decision in the controller. Sometimes you need to redirect to a whole different site. This is how I do redirects in Zend Framework 1.10:

Redirect to another controller and/or action
For this I use the Zend_Controller_Action_Helper function redirector(action, controller name)

$this->_helper->redirector('display', 'index');

This will redirect to the displayAction in the indexController

Redirect to another site
For this I use the Zend_Controller_Action function redirect(url). The redirect function takes an full url as input (you can also supply an array with redirect options)

$this->_redirect('http://framework.zend.com/');

This will redirect you to the Zend Framework site

Comments are closed.

Niklas Tech Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.