发新话题
打印

Apache环境强制跳转到https

Apache环境强制跳转到https

网站申请完证书后,配置https,如果不想http访问,需要强制跳转http的访问到https,具体代码如下:<VirtualHost *:80>

    <Directory "D:/web/xxx">

        Options FollowSymLinks Includes ExecCGI

        AllowOverride All

        Require all granted

    </Directory>

    ServerAdmin 877040117@qq.com

    DocumentRoot "D:/web/xxx"

    ServerName www.xxx.com


    RewriteEngine on

    RewriteCond   %{HTTPS} !=on

    RewriteRule   ^(.*)  https://%{SERVER_NAME}$1 [L,R]


   

    ErrorLog "logs/xxx-error.log"

    CustomLog "logs/xxx-access.log" common
</VirtualHost>



测试通过。

TOP

发新话题