自从我将 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/