Skip to content

Instantly share code, notes, and snippets.

@geminorum
Last active July 5, 2021 23:33
Show Gist options
  • Save geminorum/3f4d2f464a8b603beacb81354b742e98 to your computer and use it in GitHub Desktop.
Save geminorum/3f4d2f464a8b603beacb81354b742e98 to your computer and use it in GitHub Desktop.
Force SSL
# OLD: https://www.janes.co.za/quick-tip-force-ssl-with-htaccess/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# BEGIN Redirect HTTP to HTTPS
# https://www.wpfastestcache.com/tutorial/how-to-redirect-all-http-to-https-htaccess/
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# END Redirect HTTP to HTTPS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment