在Apache2 Ubuntu 16.04中安装Letsencrypt后,HTTPS重定向次数过多

在Apache2 Ubuntu 16.04中安装Letsencrypt后,HTTPS重定向次数过多,apache2,httpd.conf,http-redirect,lets-encrypt,Apache2,Httpd.conf,Http Redirect,Lets Encrypt,安装后,lets encrypt创建了apache2-le-ssl.conf文件,并添加了以下代码 <IfModule mod_ssl.c> <VirtualHost *:443> ServerName example.com Redirect / https://www.example.com/ SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertifica

安装后,lets encrypt创建了apache2-le-ssl.conf文件,并添加了以下代码

<IfModule mod_ssl.c>
<VirtualHost *:443>

    ServerName example.com
    Redirect / https://www.example.com/
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:443>

    ServerName www.example.com
    Redirect / https://www.example.com/
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

ServerName example.com
重定向/https://www.example.com/
SSLCertificateFile/etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile/etc/letsencrypt/live/example.com/privkey.pem
Include/etc/letsencrypt/options-ssl-apache.conf
服务器名www.example.com
重定向/https://www.example.com/
SSLCertificateFile/etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile/etc/letsencrypt/live/example.com/privkey.pem
Include/etc/letsencrypt/options-ssl-apache.conf
并在apache2.conf中添加了以下内容

# HTTPS Redirect
<VirtualHost *:80>
    ServerName example.com
    Redirect / https://www.example.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName www.example.com
    Redirect / https://www.example.com/
</VirtualHost>
#HTTPS重定向
ServerName example.com
重定向/https://www.example.com/
服务器名www.example.com
重定向/https://www.example.com/
这就是我的app/.htaccess文件的外观

# Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
#    RequestHeader unset Proxy
#</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>
#取消对以下内容的注释以防止httpoxy漏洞
#见:https://httpoxy.org/
#
#请求头未设置代理
#
重新启动发动机
重写基/
重写规则^$webroot/[L]
重写规则(.*)webroot/$1[L]
这就是我的app/webroot/.htaccess的外观

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
我被重定向了太多次,这是一个错误。
我如何解决它而不重新设置

我意识到在apache2/sites enabled中存在另一个apache2-le-ssl.conf。我删除了文件。在此之后,我仍然收到一个错误,但“Err_ssl_protocol_error”:站点无法提供安全连接。我也删除了apache2/apache2-le-ssl.conf,并将此文件中的代码添加到我的sites enabled/000-default.conf文件中。我现在再次遇到重定向次数过多的错误。