Skip to content

Instantly share code, notes, and snippets.

@ThijsFeryn
Created September 18, 2017 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ThijsFeryn/77c3b2e1425b1301448b05f5b547ea4c to your computer and use it in GitHub Desktop.
Save ThijsFeryn/77c3b2e1425b1301448b05f5b547ea4c to your computer and use it in GitHub Desktop.
Force HTTPS redirect for sites behind a reverse (caching) proxy that terminates SSL
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
Header append Vary: X-Forwarded-Proto
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment