How to redirect all HTTP requests to HTTPS

前端 未结 26 2162
小鲜肉
小鲜肉 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:49

    I like this method of redirecting from http to https. Because I don't need to edit it for each site.

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    

提交回复
热议问题