How to create route that accept all requests for unexsting controllers, but leave requests for existing.
This code catch all routes
$route = new Zend_Controller_Router_Route_Regex('(\\w+)', array('controller' => 'index', 'action' => 'index')); $router->addRoute('index', $route);
how should I specify route requests like /admin/* or /feedback/* to existing adminController or feedbackController?
You should not create a route to handle that. The error controller will take care of all three kinds of the following errors:
Take a look at the documentation on how to use it correctly:
I found only the way - not to add route in case current request is about admin area
$request = $frontController->getRequest();
if (!preg_match('/knownController/', $request->getRequestUri())){
$router->addRoute('index', new Zend_Controller_Router_Route_Regex('(.*)', array('controller' => 'index', 'action' => 'index')));
}
You can also use the ErrorController to do a similar thing. Maybe if you dig into the way they implement the plugin it will help you build something that meets your needs closely?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.