如何在 nginx 中阻止任何包含“作者”一词的 url?

问题描述 投票:0回答:1

我想在 nginx 中阻止任何包含“作者”一词的 URL。

喜欢:

exmaple.com/author/exmple....
exmaple.com/?author=2/exmple....
exmaple.com/?author=4
exmaple.com/blog/?author=1
exmaple.com/blog/author/wellcome
.
.
.

我使用下面的代码,然后重新启动 nginx,但不适用于所有 URL。

location ~ author{
 deny all;
}

我该怎么办?

nginx nginx-config
1个回答
1
投票

我使用2条规则:

以下网址:

www.exmaple.com/author/exmple....
www.exmaple.com/blog/author/wellcome

我用:

location ~ author{
return 403;
}

对于以下网址:

www.exmaple.com/?author=2/exmple....
www.exmaple.com/?author=4
www.exmaple.com/blog/?author=1

我用

  if ($request_uri  ~* author ) {
        return 403;
    }
© www.soinside.com 2019 - 2024. All rights reserved.