我最近在apache2中启用了ssl,一切都很顺利,但现在每次我尝试访问http://example.com/我被重定向到https://example.com/
我查看了default.conf和apache2.conf中的一些指示,但没有找到任何指示。
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.de
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www
ServerName example.com
SSLEngine on
SSLCertificateFile /root/server.crt
SSLCertificateKeyFile /root/server.key
</VirtualHost>
我还仔细检查了所有目录中的.htaccess文件。有没有一种方法可以从重定向的位置或内容进行查找?是否有其他方法可以将所有http请求重定向到https?
打开Chrome开发工具,转到网络选项卡,单击保留日志,然后通过http加载您的网站。
如果你看到301或302重定向到https,那么服务器上的某些东西会告诉你的浏览器转到https。
如果你看到一个307重定向到gyross,那么该网站上已经或已经设置了一个严格传输安全(也称为HSTS)标头来强制https,Chrome已经缓存了该策略。这是web服务器可以用来强制执行https的安全功能。检查返回的HTTP标头以查看是否是这种情况,如果没有发送此类标头,则可以使用此页面在地址栏中查看并清除旧策略:chrome://net-internals/#hsts