nginx 重写帖子数据

标签 nginx laravel-4 url-rewriting rewrite

我需要将 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/

相关文章:

php - Laravel 4 更新 slug

IIS 7.5 URL Rewrite 规则来处理基于用户代理的请求

apache - 在apache上使用.htaccess进行url重写时如何使用#号作为 anchor ?

asp.net - 使用 ASP.NET 重定向到非 www-url 域?

javascript - 生产中的下一个js动态路由返回403错误但应该返回404。可能是什么问题?

ruby-on-rails - Nginx 和乘客依赖问题( digital ocean 部署)

Laravel 核心方法混淆

php - 为什么 artisan 不处理 Composer 更新并且不返回错误消息?

node.js - JSON 不得超过 1000000 字节

nginx - Docker反向代理到子域