Apache由http自动跳转到https的方法
更新:HHH   时间:2023-1-7


修改根目录.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} ^jenny.party|www.jenny.party$
  RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]

    #不带www自动跳转到带www
    RewriteEngine On
  RewriteCond %{http_host} ^hrsc.cc [NC]
  RewriteRule ^(.*)$ https://www.hrsc.cc/$1 [L,R=301]
</IfModule>
返回web开发教程...