【发布时间】:2016-01-26 03:34:59
【问题描述】:
我最近在 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 吗?
【问题讨论】:
-
这是最近的事,但可能对你有用:stackoverflow.com/a/33355792/998161! :)
-
我已经看到 chrome 决定将自己重定向到 https 如果它之前访问过 https 中的 url,清除历史记录/缓存为我解决了这个问题。在开发站点上启用一次 https 后,让我头疼了几分钟。
标签: php apache .htaccess redirect ssl