【问题标题】:Skip an argument when doing a 301 redirect in NGINX在 NGINX 中执行 301 重定向时跳过参数
【发布时间】:2020-10-14 12:37:22
【问题描述】:

第一次发帖。 因此,我使用此代码将特定页面从一个域重定向到另一个域。

if ( $request_filename ~ / ) { rewrite ^ https://example.net permanent; }

是否可以选择跳过该代码中包括“?d=”在内的任何内容? 我不希望重定向中包含 ?d= 之后的任何页面。

【问题讨论】:

    标签: nginx http-status-code-301


    【解决方案1】:

    如果重写后的 URL 以 ? 结尾,rewrite 将不会复制任何原始参数。

    例如:

    rewrite ^ https://example.net/? permanent;
    

    详情请见this document


    或者,使用更简单的return 表达式:

    return 301 https://example.net/;
    

    【讨论】:

      猜你喜欢
      • 2020-10-29
      • 2016-04-15
      • 2020-10-20
      • 2018-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      相关资源
      最近更新 更多