简体   繁体   English

使用 apache 和 certbot 将 HTTP 重定向到 HTTPS

[英]Redirect HTTP to HTTPS with apache and certbot

So I did the http to https redirect thing and everything works fine, but when I go to postman and let's say I have a post method and I put http://api.domain/addDevice , it should redirect to a POST method https://api.domain/addDevice but it redirect me to a GET method https://api.domain/addDevice cause I think it is the default one.所以我做了 http 到 https 重定向的事情,一切正常,但是当我去邮递员时,假设我有一个 post 方法,我把http://api.domain/addDevice ,它应该重定向到一个 POST 方法https: //api.domain/addDevice但它将我重定向到 GET 方法https://api.domain/addDevice因为我认为它是默认方法。

Do I need to change something in the sites-available, sites-enabled of apache2 or somewhere else?我是否需要更改 apache2 或其他地方的可用站点、启用站点中的某些内容?

Thank you.谢谢你。

That is sadly quite normal behaviour - for POST to POST redirect please use http status 307 not the default 302 (as 302 is undefined for other methods than GET and therefore mostly implemented in a way it always redirected from any method to GET method only).遗憾的是,这是非常正常的行为 - 对于 POST 到 POST 重定向,请使用 http 状态 307 而不是默认的 302(因为 302 未定义用于 GET 之外的其他方法,因此主要以始终从任何方法重定向到 GET 方法的方式实现)。

307 status was invented to redirect from method to the same method.发明了 307 status 以从方法重定向到相同的方法。

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM