Way to redirect the browser from the bootstrap in Zend Framework


I need to redirect according to some conditions in the bootstrap file.
It is done AFTER the front controller and routes are defined.
How do I do that?
(I know I can simply use header('Location: ….) The point is I need to use the Router to build the URL.

Best Solution

more than year later, i'm programming in ZF and I got this solution for your problem. Here is my function in bootstrap that determines where the user is logged on.

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap


protected $_front;


protected function _initViewController() 

    $this->_front = $this->getResource('FrontController');


protected function _initLogado()
    $router = $this->_front->getRouter();
    $req = new Zend_Controller_Request_Http();
    $module = $req->getModuleName();

    $auth = Zend_Auth::getInstance();
    if ($auth->hasIdentity()) {
        $this->_view->logado = (array) $auth->getIdentity();
    } else {
        $this->_view->logado = NULL;
        if ($module == 'admin') {
            $response = new Zend_Controller_Response_Http();


Related Question