Last active
June 13, 2018 03:49
-
-
Save joshcummingsdesign/306c4202b81023bbaaa4878e9f9f43d9 to your computer and use it in GitHub Desktop.
Force Redirect to Secure Protocol from .htaccess (Apache)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteCond %{HTTP_HOST} ^yoursite.com [NC] | |
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301,NC] | |
RewriteEngine On | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Force Redirect to HTTPS
If you would like to redirect everything to
https://www.yoursite.com
, make sure you have SSL certificates forwww.yoursite.com
andyoursite.com
and add these rules to your.htaccess
file.