【问题标题】:Nginx equivalent of Apache query string ruleNginx 等效于 Apache 查询字符串规则
【发布时间】:2020-03-03 23:31:44
【问题描述】:

我们最近为我们的 WordPress 网站之一迁移到 nginx 服务器。我们遇到了 Cloudflare 问题,修改了 ajax 请求的内容类型,这导致 Stripe 集成出现问题并且无法呈现。

我们用下面的代码修复了它

RewriteCond %{REQUEST_URI} \?wc-ajax=update_order_review$
Header set Content-Type text/html

在 Nginx 中尝试了以下代码

location ~ /?wc-ajax=update_order_review$ {
  add_header Content-Type text/html;
}

不幸的是,它没有用,也没有找到任何解决方案在 Nginx 中重写它。 你能帮忙解决一下吗?

提前致谢

【问题讨论】:

    标签: .htaccess nginx woocommerce


    【解决方案1】:

    您可以使用$args 访问查询字符串(不带?)和$arg_name 访问查询参数name

    Here is official Nginx doc

    所以你可以试试:

    location / {
       if ($arg_wc-ajax ~ "^update_order_review$") {
          add_header Content-Type text/html;
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-08-13
      • 2016-11-01
      • 1970-01-01
      • 2016-12-08
      • 2020-06-22
      • 2018-02-08
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多