jump to navigation

Zend Framework : Redirecting with the Redirector Helper April 13, 2011

Posted by Tournas Dimitrios in Zend Framework v1.10.

The Redirector helper allows you to use a redirector object to fulfill your application’s needs for redirecting to a new URL. It provides numerous benefits over the _redirect() method, such as being able to preconfigure sitewide behavior into the redirector object or using the built in gotoSimple($action, $controller, $module, $params) interface similar to that of Zend_Controller_Action::_forward().
The Redirector has a number of methods that can be used to affect the behaviour at redirect , read the manual . A practical example :

public function indexAction()
// Using the redirect function

*Using the redirector helper to an external link
$this->_redirector = $this->_helper->getHelper('Redirector');

*Using the redirector helper to an application's page
$this->_redirector = $this->_helper->getHelper('Redirector');
           ->setGotoSimple("this-action" ,

* Redirection from a action controller
*The first argument defines a action
*The second argument defines a controller (default is index )
$this->_helper->redirector("login" , "index");
*Creating a link
<a href="%3C?%3Cspan%20class=">php</a><a href="%3C?%3Cspan%20class="> echo $this->url(array('controller'=>'controllerName' , 'action'=>'actionName' ) ?>" > Goto-Link </a>
//also this works
<a href="/index/index"> Go-Home</a>

Read the “Utility Methods ” section on the official website .



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s