
一句话承诺:用时序图和表格,快速选对重定向码,避免缓存与方法变更带来的坑。
状态码 | 是否缓存 | 方法是否改变 | 典型用途 |
|---|---|---|---|
301 Moved Permanently | 可缓存 | 可能变更 | 域名迁移,长期重定向 |
302 Found | 不建议缓存 | 可能变更 | 临时重定向 |
307 Temporary Redirect | 不缓存 | 方法不变 | POST保持POST |
308 Permanent Redirect | 可缓存 | 方法不变 | 永久重定向且方法不变 |

server {
listen 80;
server_name old.example.com;
return 301 https://new.example.com$request_uri;
}
server {
listen 80;
server_name temp.example.com;
location /upload {
return 307 https://upload.example.com$request_uri;
}
}YAML/JSON 配置互转:批量脚本与常见格式陷阱(代码块+案例)。