Regex help. Lighttpd rewrite rule

帅比萌擦擦* 提交于 2019-12-02 11:19:29

问题


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!


回答1:


You probably want to use a negative lookahead. Something like

"^/(?!statistics)(.+)/?$" => "/index.php/$1"

And then you'll need an additional rule for statistics



来源:https://stackoverflow.com/questions/3521989/regex-help-lighttpd-rewrite-rule

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!