nicojensen.de/.htaccess
Nico Jensen 13f6b0af35 added .htaccess to _config.yaml
create a new .htaccess file
add security header to .htaccess
add cache to .htaccess
add none www redirect to .htaccess
2020-05-29 17:51:16 +02:00

41 lines
No EOL
1.9 KiB
ApacheConf

# Set redirect to non www
# ------------------------------------------------------------------------------
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# HTTP Security Header
# ------------------------------------------------------------------------------
AddCharset UTF-8 .html
Header always set Strict-Transport-Security: max-age=63072000
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options "DENY"
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Robots-Tag none
Header always set Referrer-Policy "same-origin"
Header always set Expect-CT "enforce, max-age=21600"
Header always set Content-Security-Policy "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self'; base-uri 'none'; require-trusted-types-for 'script'; frame-ancestors 'none'; form-action 'self'; block-all-mixed-content"
Header always set Feature-Policy "geolocation 'none'; midi 'none'; camera 'none'; usb 'none'; magnetometer 'none'; accelerometer 'none'; vr 'none'; speaker 'none'; ambient-light-sensor 'none'; gyroscope 'none'; microphone 'none'"
# Set browser caching
# ------------------------------------------------------------------------------
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
# End caching block