如何保留默认的 Zend 路由
我正在尝试设置有意义的网址,例如 http://www.site.com/company/department 但是它会破坏我现有的控制器/操作形状的 URL。
在我的引导程序中,我创建新路线如下:
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$route = new Zend_Controller_Router_Route(":company/:dpt", array('controller' => 'browse'));
$router->addRoute("browse", $route);
当我浏览到 http://www.site.com 时/ABC_Co/dry_goods 它会将我路由到 BrowseController 中的 IndexAction。伟大的!问题是我的其他与管理相关的 URL(例如 /company/create 等)也指向那里。
有没有办法让 Zend 首先执行其默认控制器/操作匹配,并仅在失败时恢复到浏览路由?
谢谢!
I am trying to setup meaningful URLs such as http://www.site.com/company/department however it hammers my existing URLs which are in the Controller/Action shape.
In my bootstrap, I create my new route as follows:
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$route = new Zend_Controller_Router_Route(":company/:dpt", array('controller' => 'browse'));
$router->addRoute("browse", $route);
When I browse to http://www.site.com/ABC_Co/dry_goods it routes me to IndexAction in BrowseController. Great! The problem is that my other admin-related URLS - such as /company/create, etc - are directing there too.
Is there some way to get Zend to do its default Controller/Action matching first, and revert to the Browse route only on failure?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
路线是按后进先出的方式处理的,您需要执行以下操作:
相反,您可能只想在“浏览”路线中添加“静态”组件。这将使更具体:
IMO,第二个是更好的选择
Routes are handled on LIFO, you'll need to do something like this:
Instead, you may just want to sonsider adding a "static" component to your "browse" route. That would make is more specific:
IMO, the second one is the better option