How to redirect all HTTP requests to HTTPS

前端 未结 26 2625
小鲜肉
小鲜肉 2020-11-22 00:40

I\'m trying to redirect all insecure HTTP requests on my site (e.g. http://www.example.com) to HTTPS (https://www.example.com). I\'m using PHP btw.

26条回答
  •  我寻月下人不归
    2020-11-22 00:57

    A different edge to this problem is when a Load Balancer comes into play.

    The situation is as follows: - Traffic from browser to Load Balancer, and back, is (should be) HTTPS - Traffic between Load Balancer and actual WebServer is HTTP.

    So, all server request variables in PHP or Apache show that the connection is just HTTP. And the HTTP and HTTPS directories on the Server are the same.

    The RewriteCondition in the approved answer does not work. It gives either a loop or it just doesn't work.

    Question is: How to get this working on a Load Balancer.

    (Or is the Load Balancer configured wrong. Which is what I'm hoping for because then I can move the problem over to the WebHosting company :-) )

提交回复
热议问题