Skip to content

Instantly share code, notes, and snippets.

@locvfx
Created November 11, 2017 06:08
Show Gist options
  • Save locvfx/61dffab5386248d839aca30a0872b812 to your computer and use it in GitHub Desktop.
Save locvfx/61dffab5386248d839aca30a0872b812 to your computer and use it in GitHub Desktop.
Force https
# -----------------------Force https----------------------------------------------------------
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteOptions InheritDownBefore
# This prevents the rule from being overrided by .htaccess files in subdirectories.
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [QSA,R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# ----------------------\Force https----------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment