【问题标题】:How to make Nginx rule work for deep links?如何使 Nginx 规则适用于深度链接?
【发布时间】:2019-01-02 06:20:27
【问题描述】:

下面的nginx规则-

 rewrite ^/component(/.*)$ $1 last;

适合

https://example.domain.com/component/aaa

但是如果 URL 有更多的斜杠意味着 URL 更深,则上述规则不起作用示例-

https://example.domain.com/component/aaa/bbb 或 https://example.domain.com/component/aaa/bbb/CCC

失败了。请帮忙!

【问题讨论】:

  • 尝试在 (/.*) 之后添加 +
  • @user101 运气还是一样。

标签: regex nginx url-rewriting


【解决方案1】:

在sn-p下面试试这个,

^\/component(\/.*)$

我已使用https://regex101.com/ 在线工具来处理您@DineshRawat 提到的测试用例

【讨论】:

    猜你喜欢
    • 2010-11-14
    • 2017-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-10
    • 1970-01-01
    相关资源
    最近更新 更多