Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save meena-erian/4c743848151c8b6ab2dc342ed29af422 to your computer and use it in GitHub Desktop.

Select an option

Save meena-erian/4c743848151c8b6ab2dc342ed29af422 to your computer and use it in GitHub Desktop.
Apache configuration to force clients to load resources over secure HTTPS only
RewriteEngine On
# Non-www for portacode.com & remove trailing slashes
RewriteCond %{HTTP_HOST} ^www\.portacode\.com$ [NC]
RewriteRule ^(.*)\/$ https://portacode.com/$1 [L,R=301]
# End Non-www for portacode.com
# Force SSL
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Header append Content-Security-Policy: "upgrade-insecure-requests;"
Header append Strict-Transport-Security: "max-age=86400"
# End Force SSL
# All to index.php
RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
RewriteRule ^(.*)$ /index.php?resource=$1 [L,QSA]
# End All to index.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment