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.