Skip to content

Instantly share code, notes, and snippets.

@trplll
Created December 2, 2016 13:55
Show Gist options
  • Save trplll/3dec037dcc2e62bde0efc530b0643353 to your computer and use it in GitHub Desktop.
Save trplll/3dec037dcc2e62bde0efc530b0643353 to your computer and use it in GitHub Desktop.
Apache .htaccess redirect configurations
#Forces any http request to be rewritten using https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#also forces directly linked resources (images, css, etc.) to use https
#RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#force a domain to only use SSL SSLRequireSSL directive with the +StrictRequire
#SSLOptions +StrictRequire
#SSLRequireSSL
#SSLRequire %{HTTP_HOST} eq "example.com"
#ErrorDocument 403 https://example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment