【发布时间】:2018-08-09 08:08:10
【问题描述】:
请帮助我使用 nginx:
网址www.server.com/products/customer/books
应该是www.server.com/customer/products/books
所以我需要将/products/ 与/customer/ 交换
【问题讨论】:
标签: nginx url-rewriting
请帮助我使用 nginx:
网址www.server.com/products/customer/books
应该是www.server.com/customer/products/books
所以我需要将/products/ 与/customer/ 交换
【问题讨论】:
标签: nginx url-rewriting
是的,您可以通过重写来做到这一点。将以下内容添加到您的服务器块:
rewrite ^/customer/products/(.*)$ /products/customer/$1 last;
或者,如果您有多个 URL(即客户和企业),您可以这样做:
rewrite ^/(customer|business)/products/(.*)$ /products/$1/$2 last;
【讨论】:
rewrite ^/(customer|business)/products/(.*)$ /products/(customer|business)/$1 last; 或 rewrite ^/(.*)/products/(.*)$ /products/$1/$2 last; ???