Skip to content

Instantly share code, notes, and snippets.

@egulhan
Created April 7, 2019 09:59
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 egulhan/1d8752498a18db07884d4f389c1a76ff to your computer and use it in GitHub Desktop.
Save egulhan/1d8752498a18db07884d4f389c1a76ff to your computer and use it in GitHub Desktop.
use these force HTTPS apache directives (in .htaccess) if you have proxied server (such CloudFlare) or you are using a shared hosting
RewriteEngine On
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# Redirect to https version
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment