Nginx使用http->丢失POST变量. https重定向 [英] Nginx loses POST variable with http -> https redirect

查看:420
本文介绍了Nginx使用http->丢失POST变量. https重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个使用重定向方法的网站...

I have a website set up that uses the redirect method...

server {
    listen 80;
    server_name example.org;
    return 301 https://$server_name$request_uri;
}

但是,当页面发布到" http://example.com "时,它会重定向到" https://example.com ,并在此过程中删除POST.

However when a page is posted to "http://example.com" it redirects to "https://example.com" and in the process, it strips the POST.

我知道这是工作原理,但是我需要采取以下措施之一...

I recognize this is how it works, however I need to somehow do one of the following...

  • 从http-> https进行重定向,同时保持POST变量不变
  • 在重定向过程中将POST变量转换为GET变量(效果很好)
  • 重定向除一个文件夹之外的所有内容

有什么建议吗?我有点迷路了...

Any suggestions? I'm a bit lost...

推荐答案

如果您愿意放弃永久"重定向状态,我相信307重定向而不是301重定向将保留POST.实际上,存在一个永久重定向并保留了该帖子,即308,但浏览器和其他用户代理尚未很好地采用它.

If you are willing to forgo the "permanent" redirect status, I believe a 307 redirect instead of a 301 will preserve the POST. There actually is a redirect that is permanent and preserves the post, a 308, but it isn't well adopted yet by browsers and other user agents.

这篇关于Nginx使用http->丢失POST变量. https重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆