跨aws elb将http的Apache url重写为https

跨aws elb将http的Apache url重写为https,apache,.htaccess,url-rewriting,http-status-code-404,httpd.conf,Apache,.htaccess,Url Rewriting,Http Status Code 404,Httpd.conf,我正在尝试通过aws弹性负载平衡器将整个域从http重定向到https My 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} ^/te

我正在尝试通过aws弹性负载平衡器将整个域从http重定向到https

My 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


谁能告诉我问题出在哪里。

以下更改对我很有效

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}后^在$condition下,一切按预期开始工作。

最好使用重定向: