【问题标题】:PCRE Nginx regexp matching any of words or ending with suffixPCRE Nginx 正则表达式匹配任何单词或以后缀结尾
【发布时间】:2020-07-20 20:25:24
【问题描述】:

如何编写包含 foo|bar|baz 或以 /beautifu.html 结尾的 Nginx 正则表达式数学位置?

sth like location ~ ^/.*(foo|bar|baz)/.*$ 但也匹配 .*/beautiful.html

【问题讨论】:

  • | 运算符用于分隔替代正则表达式。 ^/.*.*$ 是不必要的。你可以试试:location ~ (foo|bar|baz)/|/beautiful.html$ { ... }

标签: regex nginx pcre nginx-location


【解决方案1】:

只需在美元符号前添加/beautifu.html 以确保 URL 以 /beautifu.html 结尾

【讨论】:

  • (重新)阅读问题:“位置包含foo|bar|baz/beautiful.html结尾”
猜你喜欢
  • 1970-01-01
  • 2022-08-02
  • 1970-01-01
  • 2021-09-21
  • 2016-06-21
  • 2013-08-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多