zend 路由排除一个字符串
我定义的
routes.kategoriler.route = ":lang/categories/:cat/:name"
routes.kategoriler.defaults.controller = "category"
routes.kategoriler.defaults.action = "index"
routes.categories.route = ":lang/:type/:cat/:name"
routes.categories.defaults.controller = "types"
routes.categories.defaults.action = "index"
类型捕获“类别”一词。我在前面和后面都放了定义,但没办法。你能提供一个解决方案吗?
I defined
routes.kategoriler.route = ":lang/categories/:cat/:name"
routes.kategoriler.defaults.controller = "category"
routes.kategoriler.defaults.action = "index"
routes.categories.route = ":lang/:type/:cat/:name"
routes.categories.defaults.controller = "types"
routes.categories.defaults.action = "index"
type catches "categories" word. I put definitions before and after but no way. Can you offer a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用类型要求不匹配“类别”。像这样:
遗憾的是我的正则表达式技能不是顶尖的,所以你可能想重写它(它有点难看,它不赞成任何包含“类别”的内容,但它给了你这个想法。)
Use a requirement for type to do not match 'categories'. Like this:
Sadly my regex skills aren't on the top, so you might want to rewrite it (It's a little ugly, and it disapproves anything that contains 'categories', but it gives you the idea.)
使用来自的提示
正则表达式匹配不包含单词的行? 问题
解决了我的
using hint from
Regular expression to match a line that doesn't contain a word?
Solved my case
为了能够接受除“类别”完全匹配之外的任何内容,请使用下面的正则表达式,
这将允许您将类型用作“我的类别”或“产品类别”或任何其他不完全匹配的内容“类别”
To be able to accept anything except the exact match of "categories" use the below regexp
this will allow you to use the type as "my-categories" or "categories-of-products" or anything else that is not an exact match of "categories"