CodeIgniter路由
我需要编写一个 CI 路由,以便加载正确的控制器。我想做的是编写一条排除“features”控制器的路由。这是我的路线(但第一个不起作用)。
$route['(\w{2})/(\w{2})/products/([\w]+!features)'] = "products/products/$3"; // folder/controller/method
$route['(\w{2})/(\w{2})/products/features/([\w]+)'] = "products/features/$3"; // folder/controller/method
我想要发生的是顶行应该加载任何不是功能控制器的控制器。但我发现两条线之间存在冲突。我尝试将“!features”放置在行中的几个不同位置,带引号和不带引号,但我仍然可以加载功能控制器或加载产品控制器中的其他方法之一。但不是两者兼而有之。有人可以帮忙吗?谢谢。
I need to write a CI route so that it loads the right controller. What I want to do is write a route that excludes the "features" controller. Here are my routes (but the first one doesn't work).
$route['(\w{2})/(\w{2})/products/([\w]+!features)'] = "products/products/$3"; // folder/controller/method
$route['(\w{2})/(\w{2})/products/features/([\w]+)'] = "products/features/$3"; // folder/controller/method
What I want to have happen is the top line should load any controller that is not the features controller. But I am getting conflicts between the two lines. I've tried placing the "!features" in a couple of different places in the line, with and without quotes and I'm still getting either the features controller to load or one of the other methods in the products controller to load. But not both. Can someone help out here? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将第一行更改为:
(?!foo)
是负向前瞻,如果后面的任何内容与foo
匹配,则失败。$
表示字符串结尾,是为了确保features
不是较长单词的一部分。Try changing the first line to:
(?!foo)
is a negative lookahead, if fails if whatever is following it matchesfoo
.$
means end of string, and is there to make sure thatfeatures
is not part of a longer word.