正则表达式帮助。 Lighttpd重写规则
我对正则表达式不太熟悉,但要求我修改lighttpd重写规则。
url.rewrite = (
"^/(.+)/?$" => "/index.php/$1"
)
我想从上面的贪婪模式中排除一条路径,这样它就不会回退到index.php。
换句话说,很简单:匹配“统计”以外的任何内容。但我就是无法在正则表达式中得到正确的结果。
例如:
http://www.foo.com/anything/
→index.php/anything
http://www.foo.com/statistics/
→statistics/index.php
您能给我一个实现这一目标的提示吗?
谢谢你!
I am not very familiar with Regular expression, but I am asked to modify a lighttpd rewrite rule.
url.rewrite = (
"^/(.+)/?$" => "/index.php/$1"
)
I want to exclude a path from the above greedy pattern, so that it won't fall back to index.php.
In words, it is simple: Match anything other than "statistics". But I just couldn't get it right in regex.
For example:
http://www.foo.com/anything/
→index.php/anything
http://www.foo.com/statistics/
→statistics/index.php
Would you please show me a hint to achieve that?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想使用负前瞻。然后
你需要一个额外的统计规则
You probably want to use a negative lookahead. Something like
And then you'll need an additional rule for statistics