gpt4 book ai didi

nginx 重写帖子数据

转载 作者:行者123 更新时间:2023-12-04 10:24:44 24 4
gpt4 key购买 nike

我需要将 POST 数据保存到不同的 url

重写有效,但发布数据丢失

需要将数据从 user_info.php 发布到 userhistory

 location  ~ user_info.php {
rewrite ^/.* http://testing.com/userhistory permanent;
}

数据丢失。如何保存数据?

最佳答案

你只需要写一个带有 HTTP 状态码的 Nginx 重写规则 307308 :

location  ~ user_info.php {
return 307 http://testing.com/userhistory;
}

Http 状态码 307308应该用来代替 301因为它将请求方法从 POST 更改为 GET。引用
https://tools.ietf.org/id/draft-reschke-http-status-308-07.html#introduction

还通过 return 重定向与 rewrite 相比更好根据 nginx 文档: https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#taxing-rewrites

关于nginx 重写帖子数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27795068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com