【问题标题】:Regex to block url in nginx正则表达式阻止 nginx 中的 url
【发布时间】:2020-11-09 01:28:52
【问题描述】:

我想阻止对结尾有多余字符的 url 的访问。

例如我希望 nginx 阻止对https://www.example.com/url-pattern/amp/extra-chars/more-extra的请求

但希望它允许https://www.example.com/url-pattern/amphttps://www.example.com/url-pattern/amp/

这行得通吗?

location .*\/amp\/. {
   deny all
}

请指导。

【问题讨论】:

    标签: regex nginx url url-pattern


    【解决方案1】:

    自己解决了。如果有人正在寻找相同的解决方案

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

    【讨论】:

    • 这个应用在哪里?请,谢谢
    • 你可以将它应用到你的 nginx 配置文件中,其中指定了位置规则。
    • 小莱博夫斯基,谢谢。
    猜你喜欢
    • 2013-07-02
    • 2017-01-08
    • 1970-01-01
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 2021-03-15
    • 2017-10-15
    • 1970-01-01
    相关资源
    最近更新 更多