Skip to content

Instantly share code, notes, and snippets.

@joshcummingsdesign
Last active June 13, 2018 03:49
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 joshcummingsdesign/306c4202b81023bbaaa4878e9f9f43d9 to your computer and use it in GitHub Desktop.
Save joshcummingsdesign/306c4202b81023bbaaa4878e9f9f43d9 to your computer and use it in GitHub Desktop.
Force Redirect to Secure Protocol from .htaccess (Apache)
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]
@joshcummingsdesign
Copy link
Author

Force Redirect to HTTPS

If you would like to redirect everything to https://www.yoursite.com, make sure you have SSL certificates for www.yoursite.com and yoursite.com and add these rules to your .htaccess file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment