在nginx中重定向期间重命名特定的查询参数

时间:2017-10-21 09:43:09

标签: redirect nginx

我希望将/catalogsearch/result/?q=[keyword]重定向到/products?keyword=[keyword]。以下规则有什么问题?

location ~ /catalogsearch/result/?q=(.*) {
    rewrite ^ /products?keyword=$1 permanent;
}

1 个答案:

答案 0 :(得分:1)

?及其后的任何内容(查询字符串)不属于location和{{}使用的规范化URI 的一部分1}}指令。

假设只有一个参数,您可以使用$arg_ family of variables

访问它
rewrite
相关问题