【问题标题】:HTTPS under Amazon EBS + Apache on ubuntu on EC2 not redirecting HTTPEC2 上 ubuntu 上 Amazon EBS + Apache 下的 HTTPS 不重定向 HTTP
【发布时间】:2018-05-12 13:06:28
【问题描述】:

我有一台运行 ubuntu 16.04 和 Apache2 的 EBS 机器,它正在接收来自 EBS 的 HTTPS 请求。我在尝试将 HTTP 请求重定向到 HTTPS 时遇到问题。

到目前为止,我尝试使用 .htaccesmod_rewrite 进行重定向。

.htaccess:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

如何将 HTTP 请求重定向到 HTTPS?

【问题讨论】:

    标签: apache .htaccess amazon-web-services ubuntu


    【解决方案1】:

    试试这样:

    重写引擎开启 RewriteCond %{HTTPS} 关闭 重写规则 (.*) https://%{SERVER_NAME}/$1 [R,L]

    【讨论】:

    • 当我尝试访问 url 时,我收到“太多重定向”。
    • 所以您的页面可能会将您引导回 HTTP。
    【解决方案2】:

    我找到了解决办法。

    我没有使用 .htaccess 文件,而是在 apache .conf 文件中编写了规则。

    这里是:

    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} =http
    RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
    

    【讨论】:

      猜你喜欢
      • 2018-03-09
      • 1970-01-01
      • 1970-01-01
      • 2014-11-24
      • 2018-08-17
      • 1970-01-01
      • 2013-09-27
      • 2016-02-04
      • 2015-01-10
      相关资源
      最近更新 更多