Apache环境下强制跳转到https

2022-01-04 0 321
七牛源码默认解压密码xxxile.com

修改Apache相关配置文件,强制所有http跳转到https,假设网站域名为xxx.com。

1、在httpd-ssl.conf中 下面增加设置:

DocumentRoot “D:/web/xxx”
ServerName xxx.com:443
ServerAdmin admin@example.com
ErrorLog “D:/xampp/apache/logs/xxx_https_error.log”
TransferLog “D:/xampp/apache/logs/xxx_https_access.log”
2、在httpd-vhosts.conf文件的虚拟域名配置增加以下内容:

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]
这样,当输入 www.xxx.com 访问网站时,会自动跳转到 https://www.xxx.com

完整的记录为:



Options FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted

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

七牛源码 技术教程 Apache环境下强制跳转到https https://qnymz.com/2394.html

客服QQ598842012

评论
暂无评论