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.