Apache由http自动跳转到https的多种方法

2019-10-10 15:34:12王振洲

PS:下面再看下Apache由http自动跳转到https的方法,具体内容介绍如下所示:

修改根目录.htaccess文件

<IfModule mod_rewrite.c>
 Options +FollowSymlinks
 RewriteEngine On
#thinkphp去掉index.php
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
 #http自动跳转到https
 RewriteCond %{SERVER_PORT} !^443$
 #只有匹配对应的域名才会跳转
 RewriteCond %{SERVER_NAME} ^hrsc.cc|www.hrsc.cc$
 RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]
</IfModule>

总结

以上所述是小编给大家介绍的Apache由http自动跳转到https的多种方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对易采站长站网站的支持!