我负责我的邮件服务器,我是 Debian 和邮件服务器的新手,我遇到问题,安装 SSL 证书后,页面仍然显示 http:// 而不是 https://,我使用这个命令来查看root@mail:/# apachectl -S
输出如下
*VirtualHost 配置:
*:80 mail.12345.com (/etc/apache2/sites-enabled/000-default.conf:1)
*:443 mail.12345.com (/etc/apache2/sites-enabled/000-default.conf:31)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex ssl-stapling-refresh: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33*
我的(/etc/apache2/sites-enabled/000-default.conf)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Redirect / https://webmaster@localhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
SSLEngine On
SSLCertificatefile /etc/ssl/1/1.pem
SSLCertificateChainfile /etc/ssl/1/1.ca-bundle
SSLCertificatekeyfile /etc/ssl/1/1.key
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{}/$1 [R,L]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
为什么我无法重定向 https 页面?
答案1
RewriteCond %{HTTPS} !=on
将在 HTTP 连接上匹配。您不小心将“HTTP -> HTTPS”规则放在了服务器的 HTTPS 部分。只需将上面的 VirtualHost 中的三行移开即可。