1 Answer
- Newest
- Most votes
- Most comments
0
When you have a CDN in front of a web-server, you need to examine the content of the X-Forwarded-Proto header that the CDN adds:
You should probably change the line:
RewriteCond %{HTTPS} off
to something like:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
If you also want to have the redirect for traffic that comes in directly and not via the CDN add a second Rewrite Condition as follows:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Relevant content
- asked a year ago
- asked 20 days ago
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 2 years ago
still throwing error, too many redirects
Your best bet then to understand what is happening is to turn on mod_rewrite's logging. If you are using Apache 2.4 and up - you need to do this with
LogLevel alert rewrite:trace3
in your main config (not .htaccess). Refer to https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging. Then examine your logs to see why and at what step it keeps redirecting.