views:

245

answers:

4

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?

A: 

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')));  
}    
se_pavel
+1  A: 

You might want to look at this post where i asked a similar question http://stackoverflow.com/questions/2520058/route-all-requests-through-pagecontroller-except-existing-controllers-zend-frame

ChrisR
A: 

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?

Steve
A: 

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

DASPRiD