找到网站根目录的.htaccess文件,添加如下代码
RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
开启重写引擎,凡是访问80端口的请求,都转到https。
RewriteEngine OnRewriteCond %{HTTPS} !=onRewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
开启重写引擎,凡是访问请求不是走的HTTPS的请求,都转到https。
Apache 强制Http跳转Https
原文地址:https://www.cnblogs.com/peteremperor/p/10142909.html