Zend> configuration for finding unique regular expression routes

I use the zend framework for my application, and I used several regex routes to route users to specific controllers and actions based on parameters in the url.

But when the url pattern does not match, I get a 404 error, for example: Page not found.

How can I specify the configuration so that when the regex path does not match the specified URLs, control is routed to the default controller and action?

FYI, I would like to go to the default "index" and "index" controller

+3
source share
3 answers

Solution 1:

Front Controller .

$front->setParam('useDefaultControllerAlways', true);

2:

ErrorController :   

class ErrorController extends Zend_Controller_Action {

    public function errorAction() {
        $this->_forward('index', 'index');
    }

}

?>
+1

" " , . IIRC, Router (?) , . " " true.

+3

I use ACLto create custom error

class Management_Access extends Zend_Controller_Plugin_Abstract{

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
    ....
    ....
    ....
    ....
    $controller = $request->controller;
    $action = $request->action;

    if (!$acl->has($controller)) {

        $request->setControllerName('error');
        $request->setActionName('notfound');

    }

Modification can help you.

+2
source

All Articles