1

例如,要匹配 path 下的所有文件(不是 jpg、png、gif)common,例如

匹配:

/common/foo.php
/common/foo.doc

不匹配:

/common/foo.jpg
/common/foo.gif
/foo

目前我正在使用:

\/common\/.*^(?:jpg|png|gif)$ 
4

2 回答 2

1

负面的回顾将接近您当前的尝试:

\/common\/.*(?<!\.jpg|\.png|\.gif)$

这匹配以“/common/”开头但不以“.jpg”、“.png”或“.gif”结尾的所有内容。

演示

于 2012-11-08T16:20:01.887 回答
0
location /common/ {
    # here configuration for not jpg, png, gif

    location ~ \.(?:png|gif|jpg)$ {
        # here configuration for jpg, png, gif
    }
}
于 2012-11-08T19:41:32.703 回答