求一个 nginx 配置,需求如下:网站的目录结构是 /html/年 /栏目名 /稿件 id,现在需要屏蔽,地址类似: https://example.com/html/2016/news/1.html,现在需要屏蔽 2016 年整年的稿件,除了某个栏目的,就是: https://example.com/html/2016/news/1.html 不能打开,但是 https://example.com/html/2016/ok/2.html 可以打开,就是要匹配到栏目名称是 ok 的,可以打开
1
InDom Sep 26, 2021
盲写的哈,不知道对不对。
location ~ ^/html/2016/(news|health)/ { return 403; } |
3
alvinbone88 Sep 26, 2021
location /html/2016/ {
return 403; } location /html/2016/ok/ { // 自定义配置 } |
4
mxm145 OP @alvinbone88 测试确实可以实现,但是要把顺序反过来放,多谢
|