Nginx重写-URL中的交换路径

Nginx重写-URL中的交换路径,nginx,url-rewriting,Nginx,Url Rewriting,请帮助我使用nginx: urlwww.server.com/products/customer/books 应该是www.server.com/customer/products/books 因此,我需要将/products/与/customer/交换。是的,您可以通过重写来完成此操作。将以下内容添加到服务器块: rewrite ^/customer/products/(.*)$ /products/customer/$1 last; 或者,如果您有多个URL(即客户和业务),您可以执行以下

请帮助我使用nginx:

url
www.server.com/products/customer/books
应该是
www.server.com/customer/products/books


因此,我需要将
/products/
/customer/
交换。是的,您可以通过重写来完成此操作。将以下内容添加到服务器块:

rewrite ^/customer/products/(.*)$ /products/customer/$1 last;
或者,如果您有多个URL(即客户和业务),您可以执行以下操作:

rewrite ^/(customer|business)/products/(.*)$ /products/$1/$2 last;

谢谢你的回答!但是书籍不是一个类别,有很多类别。我应该在最后使用$??所以,只有客户和产品被重新安排,但在他们之后,会有一些东西……太棒了!!!非常感谢!最后一个问题-如果将来我有客户以外的东西,例如业务?我应该使用此重写-
rewrite^/(客户|业务)/产品/(.*)$/产品/(客户|业务)/$1
最后重写^/(.*)/products/(.*)$/products/$1/$2???第二个是正确的。我也把它加到了我的答案中。