Regex location /.* with nginx



我想拒绝所有类型的URI,比如/*我试过这个,但没有计算

location ~* ^/..* {
deny all;
}

当我尝试时:

curl -H "Host: xxxxx.xxxxx.xxxxx" "http://localhost:8000/.env" -I
HTTP/1.1 404 Not Found

有什么可以帮忙的吗?我应该有401,而不是。。。谢谢你的帮助!

您确定您的URL没有被优先级较高的位置捕获吗?https://nginx.org/en/docs/http/ngx_http_core_module.html#location

您为捕获时段(.(指定的位置块看起来是正确的。此外,拒绝将是403,而不是401。

最新更新