Skip to content

Instantly share code, notes, and snippets.

@nikcree
Last active October 7, 2020 22:42
Show Gist options
  • Save nikcree/37c4a3204657ed8e9c75891e0ba66ca6 to your computer and use it in GitHub Desktop.
Save nikcree/37c4a3204657ed8e9c75891e0ba66ca6 to your computer and use it in GitHub Desktop.
# BEGIN Add Secure and httpOnly Flags to Every Set-Cookie Response in Apache httpd
Header always edit Set-Cookie (.*) "$1; HTTPOnly"
Header always edit Set-Cookie (.*) "$1; Secure"
# END Add Secure and httpOnly Flags to Every Set-Cookie Response in Apache httpd
# BEGIN SSL Rewrite
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END SSL Rewrite
# BEGIN HSTS Support
# To ensure all urls are redirected to SSL
Header add Strict-Transport-Security: "max-age=15768000"
# END HSTS Support
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# LBROWSERCSTART Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/xhtml-xml "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
# END Caching LBROWSERCEND
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP
# Security drive-by-downloads
Header set X-Content-Type-Options nosniff
# Security Cross-site scripting
Header set X-XSS-Protection "1; mode=block"
# Security Clickjacking
Header always append X-Frame-Options SAMEORIGIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment