tags:

views:

43

answers:

1

Hi, 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  A: 

You probably want to use a negative lookahead. Something like

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

And then you'll need an additional rule for statistics

JonNeale