Redirect with Zend Framework

Once I wrote about redirecting with Zend Framework, but what I missed back than was a common mistake. Although the code from my post is working, to be completely correct after redirecting I’d to add an exit() statement.

This is important because the header is changed and if something goes after the redirect there will be some problems. Finally the correct snippet is:

public function() {
	$this->_redirect('some_url');
	exit();	
}

One thought on “Redirect with Zend Framework

  1. You can use options instead:

    $this->_redirect($this->view->url(array(), null, true), array(‘exit’ => true));

    to redirect on main. Take notice about:

    array(‘exit’ => true)

Leave a Reply

Your email address will not be published. Required fields are marked *