【问题标题】:Apache url rewrite for http to https across aws elb跨 aws elb 将 http 的 Apache url 重写为 https
【发布时间】:2018-02-28 11:46:13
【问题描述】:

我正在尝试跨 aws 弹性负载均衡器将我的整个域从 http 重定向到 https。

我的 urlrewrite.conf (Apache/2.2.15)

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} !^on$
RewriteCond %{REQUEST_URI} ^/testdemo/
RewriteRule ^/(.*) /web/testcontroller?url=$1 [PT]

以上规则是将主页从http重定向到https。但是进入testdemo虚拟目录后得到文件“404 Not Found”

谁能告诉我这是什么问题。

【问题讨论】:

标签: apache .htaccess url-rewriting http-status-code-404 httpd.conf


【解决方案1】:

以下更改对我有用。

RewriteEngine On

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

RewriteCond %{REQUEST_URI} ^/testdemo/
RewriteRule ^/(.*) /web/testcontroller?url=$1 [PT]

删除“RewriteCond %{HTTPS} !^on$”条件后,一切开始按预期工作。

【讨论】:

    猜你喜欢
    • 2015-06-27
    • 2014-09-20
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2018-04-15
    • 1970-01-01
    • 2018-03-07
    • 2018-02-20
    相关资源
    最近更新 更多