zend路由正则表达式问题
我试图在 ini 文件中创建一条路由来匹配以下 URL,但没有成功。
/add-announce.html
/add-announce-books-53.html
我的路线是这样的:
routes.add_announcement.type = "Zend_Controller_Router_Route_Regex"
routes.add_announcement.route = "/add-announce(-[a-zA-Z_]+)?(-[\d]+)?.html"
routes.add_announcement.defaults.module = announcement
routes.add_announcement.defaults.controller = frontend
routes.add_announcement.defaults.action = add
routes.announcements.defaults.catName = null
routes.announcements.defaults.catId = null
routes.add_announcement.map.catName = 1
routes.add_announcement.map.catId = 2
I am trying to make a route in the ini file to match the following URLs, but I have been unsuccessful.
/add-announce.html
/add-announce-books-53.html
My route is this:
routes.add_announcement.type = "Zend_Controller_Router_Route_Regex"
routes.add_announcement.route = "/add-announce(-[a-zA-Z_]+)?(-[\d]+)?.html"
routes.add_announcement.defaults.module = announcement
routes.add_announcement.defaults.controller = frontend
routes.add_announcement.defaults.action = add
routes.announcements.defaults.catName = null
routes.announcements.defaults.catId = null
routes.add_announcement.map.catName = 1
routes.add_announcement.map.catId = 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许因为你的匹配项开头有“-”?,你可以尝试使用:
编辑:我刚刚发现错误,你设置了错误的映射值:
相反你必须这样做:
还有
routes.announcements。 defaults.catName 不应该是routes.add_announcement.defaults.catName 吗?
Maybe because your matches has '-' at the beginning?, Can you try with:
EDIT: I just found the error, you set the mapped values wrong:
instead you have to do it like this:
Also
routes.announcements.defaults.catName
shouldn't beroutes.add_announcement.defaults.catName
?