apache - SSL 重定向太多 - Apache

标签 apache ssl redirect

自从我将 SSL 证书放在 certbot 上后,我的网站上出现了臭名昭著的“太多重定向”错误。

我在这里花了几个小时来寻找解决我问题的方法,尝试了不同的解决方案,但没有一个对我有效。

关于服务器的一些背景信息:Debian 9 和 Apache2(都是最新的)

我正在努力处理我的 VirtualHost 文件以摆脱这个“太多重定向”错误。 其中有两种,一种用于非 HTTPS 连接,一种用于 HTTPS 连接,当然两者都在 Apache 中激活。

这里是非 HTTPS 配置文件(非常简单)

<VirtualHost *:80>
ServerAdmin contact@website.com
ServerName website.com
Redirect permanent / https://www.website.com/
</VirtualHost>

<VirtualHost *:80>
ServerAdmin contact@website.com
ServerName www.website.com
Redirect permanent / https://www.website.com/
</VirtualHost>

这是HTTPS配置文件

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin contact@website.com
    ServerName website.com
    Redirect permanent / https://www.website.com/

SSLCertificateFile /etc/letsencrypt/live/website.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/website.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin contact@website.com
    ServerName www.website.com
    DocumentRoot /var/www/html

    <Directory /var/www/html>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

SSLCertificateFile /etc/letsencrypt/live/website.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/website.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

如您所见,我希望“官方”地址为“https://www.website.com”并且所有连接都没有“www”。和/或“https”被重定向到这个地址。

有人可以帮助我吗? 非常感谢!

最佳答案

我使用 CloudFlare,它突然停止工作并出现此错误。我将 CloudFlare SSL 设置从灵活更改为完整,这解决了我遇到的问题。

关于apache - SSL 重定向太多 - Apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48477427/

相关文章:

apache - 如何使用条件重定向 .htaccess 中的 URL?

Apache : Restrict access to URI, 不是资源

javascript - 启用js重定向到apache服务器的私有(private)文件夹

apache - apache Drill 是否可以执行更新、删除、插入操作

python - httplib.HTTPSConnection 在并发环境中导致 SSL 错误

django - 如何为 Azure 中的 django 项目获取 SSL 证书?

redirect - 在 vim 中,如何重定向 vimscript 函数的输出?

sql - 如何正确格式化 "select top 1000 * from schema.table_name;"以在 Toad 4 Apache Hadoop 中工作?

android - SSL 固定客户端加密

redirect - Ubuntu : Port forwarding to a guest VM 上的 KVM