【问题标题】:Nginx redirect url with param带有参数的 Nginx 重定向 url
【发布时间】:2018-11-26 17:29:18
【问题描述】:

如何创建具有 url 参数的重定向?

例如,我需要: /testing/?id=123 重定向到/testing/123

我试过了 rewrite ^/testing/?id=(.*)$ /testing/$1 redirect; 但我只收到404。

如果我不使用 url 参数而只是执行类似的操作 rewrite ^/testing/(.*)$ /anothertest/$1 redirect; 有效。

【问题讨论】:

    标签: nginx


    【解决方案1】:

    你可以试试

    rewrite ^/testing/$ /testing/$arg_id? redirect;
    

    这会将用户从/testing/?id=123 重定向到/testing/123。

    【讨论】:

      猜你喜欢
      • 2015-01-20
      • 1970-01-01
      • 1970-01-01
      • 2022-07-01
      • 1970-01-01
      • 2017-04-12
      • 2014-04-07
      • 1970-01-01
      相关资源
      最近更新 更多