我正在尝试在ini文件中创建一个匹配以下网址的路由,但我没有成功。
/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
答案 0 :(得分:1)
也许是因为你的比赛开头有' - ',你可以尝试:
routes.add_announcement.route = "add-announce(?:-([a-zA-Z_]+))?(?:-([\d]+))?.html"
编辑:我刚发现错误,你将映射值设置错误:
routes.add_announcement.map.catName = 1
routes.add_announcement.map.catId = 2
相反,你必须这样做:
routes.add_announcement.map.1 = "catName"
routes.add_announcement.map.2 = "catId"
同样routes.announcements.defaults.catName
不应该是routes.add_announcement.defaults.catName
?