Nginx return 302 为什么会丢失查询参数
很多人在配置Nginx临时重定向时遇到一个奇怪的问题:用return 302 https://target.com;跳转后,浏览器地址栏里的?utm_source=xxx&utm_medium=xxx全没了。
这不是bug,而是return指令的设计行为:当你在return的目标URL里没有写问号时,Nginx不会自动把原始查询参数拼上去。
对比一下:
rewrite ^(.*)$ https://target...
return 302
-
2026.05.29 | youres | 8次围观

