4
votes

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?

3
You might want to look at this post where i asked a similar question stackoverflow.com/questions/2520058/…ChrisR

3 Answers

2
votes

You should not create a route to handle that. The error controller will take care of all three kinds of the following errors:

  • Controller does not exist
  • Action does not exsist
  • No route matched

Take a look at the documentation on how to use it correctly:

http://framework.zend.com/manual/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler.fourohfour

0
votes

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')));  
}    
0
votes

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?