php - 浏览器可以使用 POST 重定向到 url 吗?

标签 php javascript http browser

我在一个将我重定向到我自己的网络服务器 (www.myserver.com) 的页面上,但请求不是 GET 而是 POST。

起初 www.myserver.com 无法处理请求,因为我只有一个用于处理“GET/”的路由处理器。当我意识到它可能是一个 POST 重定向(在他们的指南中阅读它)时,我为“POST/”创建了一个路由处理程序并且页面被提供了。

如果我错了请更正我,以便浏览器可以使用 POST 重定向到一个 url?

最佳答案

答案是肯定的,但浏览器应该提示用户。除了 GET 和 HEAD 允许使用 302,POST 允许使用 307。来自 HTTP RFC:

307临时重定向

The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s) , since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI.

If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

您使用的是什么浏览器?

关于php - 浏览器可以使用 POST 重定向到 url 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4965251/

相关文章:

php - symfony 4 正在创建发布请求

php - 在索引中有一个动态的可选路由参数

javascript - 如果至少选中一个复选框,则应启用按钮

javascript - GraphQL 解析器奇怪地将某些字段返回为 null

php - 如何在 HTTP 服务中进行身份验证?

php - 实时服务器中的Mysql Select查询错误: Errcode: 28 - No space left on device

javascript - JavaScript 中 like 语句的概念

rest - 已完成退款的 HTTP 响应代码

javascript - 在什么情况下发出 HTTP 请求但未收到响应?

php - 使用 PHP 从远程服务器获取最后修改和其他文件信息