views:

13

answers:

1

I use ErrorHandler in my application to intercept exceptions, but I also want to be able to redirect user to error screen using URL:

class SomeController extends Zend_Controller_Action {

    public function someAction() {
        ...
        $this->_redirect('/error/device-unknown/id/12345');
    }

}

This however takes me to standard web server 404 page.

I know I could use $this->_forward() instead, but I already get target location in form of URL. Is there a way to make Zend use URL to present error screen?

A: 

Have you set up a router rewrite to accept the URL parameters and map to the error controller + action?

//example
$router = $ctrl->getRouter(); // returns a rewrite router by default
$router->addRoute(
    'user',
    new Zend_Controller_Router_Route('user/:username',
                                     array('controller' => 'user',
                                           'action' => 'info'))
);

From http://framework.zend.com/manual/en/zend.controller.router.html

pharalia