3
目前,我有這樣的事情在我的nginx.conf文件:nginx的301查詢字符串重定向
location ~ /old/page/?$ {
return 301 /new-page;
}
的問題是,查詢字符串正在從/老/頁剝離REF = XX網址?
是否可以使用上面使用的重定向方法包含查詢字符串?
目前,我有這樣的事情在我的nginx.conf文件:nginx的301查詢字符串重定向
location ~ /old/page/?$ {
return 301 /new-page;
}
的問題是,查詢字符串正在從/老/頁剝離REF = XX網址?
是否可以使用上面使用的重定向方法包含查詢字符串?
?
之後的任何內容都是查詢字符串,並且不是在location
和rewrite
指令中使用的規範化URI的一部分。有關詳細信息,請參閱this document。
如果你想保留查詢字符串,要麼將它添加到return
:
location = /old/page/ {
return 301 /new/page$is_args$args;
}
或者與rewrite
,除非?
添加查詢字符串自動附加:
rewrite ^/old/page/$ /new/page permanent;
有關位置語法,請參閱this document;有關返回/重寫,請參閱this document。
完美,結束了使用重寫。感謝您的回答! –