英文:
How to block any url contain word 'admin' in nginx?
问题
I want block any URL contain word 'author' in nginx.
Like:
exmaple.com/author/exmple....
exmaple.com/?author=2/exmple....
exmaple.com/?author=4
exmaple.com/blog/?author=1
exmaple.com/blog/author/wellcome
.
.
.
I use below code then restart nginx but not work for all URL.
location ~ author{
deny all;
}
How can I do?
我想在nginx中阻止包含'author'单词的任何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。
位置 ~作者{
拒绝所有;
}
我该怎么做?
英文:
I want block any URL contain word 'author' in nginx.
Like:
exmaple.com/author/exmple....
exmaple.com/?author=2/exmple....
exmaple.com/?author=4
exmaple.com/blog/?author=1
exmaple.com/blog/author/wellcome
.
.
.
I use below code then restart nginx but not work for all URL.
location ~ author{
deny all;
}
How can I do?
答案1
得分: 0
I use 2 rule:
for below url:
www.exmaple.com/author/exmple....
www.exmaple.com/blog/author/wellcome
I use:
location ~ author{
return 403;
}
And for below url :
www.exmaple.com/?author=2/exmple....
www.exmaple.com/?author=4
www.exmaple.com/blog/?author=1
I use
if ($request_uri ~* author ) {
return 403;
}
英文:
I use 2 rule :
for below url:
www.exmaple.com/author/exmple....
www.exmaple.com/blog/author/wellcome
I use:
location ~ author{
return 403;
}
And for below url :
www.exmaple.com/?author=2/exmple....
www.exmaple.com/?author=4
www.exmaple.com/blog/?author=1
I use
if ($request_uri ~* author ) {
return 403;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论