apache - 使用 .htaccess 将 http 重定向到 https - 使用 let-proxy 导致 ERR_TOO_MANY_REDIRECTS

标签 apache .htaccess ubuntu https lets-encrypt

我使用了一项名为lets-proxy2 (https://github.com/rekby/lets-proxy2) 的服务来自动从Let's Encrypt 获取和更新证书。
这很好用,但是当尝试在 .htaccess 文件中将 http 重定向到 https 时,我得到一个无限重定向循环,它在浏览器中抛出错误 ERR_TOO_MANY_REDIRECTS。
我尝试了几种不同的 RewriteConds 和 RewriteRules,我都遇到了同样的问题。
我正在使用的当前 .htaccess 文件是:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP:X-FORWARDED-PROTO} !(^.+)
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
我需要强制使用 https 以确保所有 http 流量都重定向到 https,但是目前尝试使用 .htaccess 文件将无法正常工作。
任何帮助,将不胜感激。

最佳答案

lets-proxy2 的作者实际上已经发布了一个修复程序来解决这里的问题 - https://github.com/rekby/lets-proxy2/issues/140 .
没有设置默认标题,所以它只是以无限循环结束。

关于apache - 使用 .htaccess 将 http 重定向到 https - 使用 let-proxy 导致 ERR_TOO_MANY_REDIRECTS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62997086/

相关文章:

.htaccess - 更改 .htaccess 文件中的 'memory_limit' 、 'post_max_size' 和 'upload_max_filesize'

.htaccess - 500 内部服务器错误而不是 404

ubuntu - 如何更改 GitLab 中 root 用户的电子邮件?

java - Apache/Tomcat 上的 Log4j 不工作

apache - 从源代码 Redhat 6 安装 Apache2 时遇到问题

apache - 使用 .htaccess 通过 index.php 重新路由所有请求,除了特定的一组请求

linux - 如何将所有 HTTPs 请求重定向到 HTTP

python - 无法将 WSGI 脚本加载为 Python 模块——500 内部服务器错误

php - eclipse : "PHP Fatal error: Call to undefined function mysqli_connect()"

python - 如何将lxml升级为python2.6