[英]Nginx redirect to another domain and append new parameter
我想所有的交通從我的重定向www.old-domain.com
到www.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.