Skip to content

Instantly share code, notes, and snippets.

@ngearing
Created July 26, 2018 23:04
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 ngearing/9be1dbbcdf654737b8e2cfb64b73f9d2 to your computer and use it in GitHub Desktop.
Save ngearing/9be1dbbcdf654737b8e2cfb64b73f9d2 to your computer and use it in GitHub Desktop.
apache .htaccess https redirect
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/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment