繁体   English   中英

Nginx重定向到另一个域并附加新参数

[英]Nginx redirect to another domain and append new parameter

我想所有的交通从我的重定向www.old-domain.comwww.new-domain.com ,同时保持所有的路径和查询参数中的URL,并追加了新的查询参数,如&from-old=true

例如

www.old-domain.com --> www.new-domain.com/?from-old=true
www.old-domain.com/home --> www.new-domain.com/home?from-old=true
www.old-domain.com/item?id=123 --> www.new-domain.com/item?id=123&from-old=true

请分享一些有关如何在Nginx中重写/返回url的想法,以实现此目的。

提前致谢!

如果要向查询字符串中的附加字符串添加可能包含或不具有查询字符串的URI,则应使用rewrite指令,因为它将正确处理边缘条件。 有关详细信息,请参见此文档

例如:

rewrite ^ $scheme://example.com$uri?from-old=true permanent;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM