Skip to content

Instantly share code, notes, and snippets.

@lucagervasi
Forked from nurtext/.htaccess
Created February 13, 2018 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucagervasi/697832789cf7b4cb8f2190fc02a9f4f8 to your computer and use it in GitHub Desktop.
Save lucagervasi/697832789cf7b4cb8f2190fc02a9f4f8 to your computer and use it in GitHub Desktop.
Tell apache we're on HTTPS if reverse proxy is serving the site using SSL
# Let apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
# Redirect to HTTPS
<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