php - 禁用 ssl/https 重定向 apache2

标签 php apache .htaccess redirect ssl

我最近在 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 重定向到 gyros,则该网站已经或已经在其上设置了 Strict-Transport-Security(又名 HSTS) header 以强制使用 https,并且 Chrome 已缓存该策略。这是 Web 服务器可用于强制执行 https 的安全功能。检查返回的 HTTP header ,看看是否是这种情况,如果没有发送此类 header ,您可以通过在地址栏中使用此页面来查看和清除旧策略:chrome://net-internals/#hsts

关于php - 禁用 ssl/https 重定向 apache2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33355861/

相关文章:

php - 我如何从 symfony2 中的表中获取逗号分隔值?

apache - 公共(public) IP 网页 "Connection Timed Out"连接时

java - "[engine] standardhost[localhost]: MAPPING configuration error for request URI"和 "No context configured to process this request"

regex - 如何将 url http 重写为 https

php - 特定页面的 apache 重写规则问题

php - 使用 laravel dusk 测试新窗口

php - 表达式引擎 fetch_action_id() 未解析

php - MySQL > JSON,导致 URL 错误

php - mod重写和查询字符串

php - 使用 AuthType Basic 登录后的 .htaccess 500 错误