Skip to content

Instantly share code, notes, and snippets.

@oliverbooth
Created January 15, 2017 06:19
Show Gist options
  • Save oliverbooth/a542ed7d39eb011c244a2f4ef50d1cc7 to your computer and use it in GitHub Desktop.
Save oliverbooth/a542ed7d39eb011c244a2f4ef50d1cc7 to your computer and use it in GitHub Desktop.
htaccess snippet for forcing HTTPS through TLS/SSL on remote-only access
# Force HTTPS
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REMOTE_ADDR} !127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
RewriteCond %{REMOTE_ADDR} !localhost
RewriteCond %{REMOTE_ADDR} !::1
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