I have one module (site) in my zend framework app. What I am trying to do is first to check if controller/action exists and if not then try to match the URL against some custom routes.
My code in _bootstrap.php is as follows:
$router = $this->frontController->getRouter();
$router->removeDefaultRoutes();
// catalog category product route
$route = new Zend_Controller_Router_Route(
':categoryIdent/:productIdent',
array(
'action' => 'view',
'controller' => 'product',
'module' => 'site',
'categoryIdent' => '',
'productIdent' => ''
),
array(
'categoryIdent' => '[a-zA-Z-_0-9]+',
'productIdent' => '[a-zA-Z-_0-9]+'
)
);
$router->addRoute('catalog_category_product', $route);
$router->addDefaultRoutes();
I know that the routes in Zend Framework are matched backwards. So I tried the following URLs.
- example.com/site/index/index -> OK (executing action/controller => index/index)
- example.com/bags/bag-7 -> OK (executing action/controller => product/view)
- example.com/index/index -> WRONG ( executing action/controller => product/view, but this should be a part from the default routes, which are defined at the end)
This is the problem and I don't understand why the default controller/action route is not applied.