0

I am trying my whole domain redirect from http to https across aws elastic load balancer.

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]

The above rules is redirecting home page from http to https. But after entering the testdemo virtual directory getting file "404 Not Found"

Can anyone tell me the what is the issue.

Suresh
  • 168
  • 2
  • 8

1 Answers1

1

The following changes worked for me.

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]

After removing "RewriteCond %{HTTPS} !^on$" condition, things started working as expected.

Suresh
  • 168
  • 2
  • 8