# START SECURITY
# Don't show errors which contain full path diclosure (FPD)
# Use that line only if PHP is installed as a module and not per CGI
# try using a php.ini in that case.
# Change mod_php5.c to mod_php7.c if you are running PHP7
php_flag display_errors Off
# Don't list directories
Options -Indexes
# Protect XMLRPC (needed for Apps, Offline-Blogging-Tools, Pingback, etc.)
# If you use that, these tools will not work anymore
#Order Deny,Allow
#Deny from all
# If you don't use the Database Optimizing and Post-by-Email features, turn off the access too:
Order Deny,Allow
Deny from all
# Prevent browser and search engines to request .log (e.g. WP DEBUG LOG) and .txt (e.g. plugins readme) files.
# Must be placed in /wp-content/.htaccess
Order Allow,Deny
Deny from all
# Hide WordPress, system & sensitive files
Order Deny,Allow
Deny from all
# Protect some other files
Order Deny,Allow
Deny from all
# Block the include-only files.
# Do not use in Multisite without reading the note in Codex!
# See: https://codex.wordpress.org/Hardening_WordPress#WP-Includes
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
# If you run multisite, comment the next line (see note above)
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
# Set some security related headers
# See: http://de.slideshare.net/walterebert/die-htaccessrichtignutzenwchh2014 (GERMAN)
Header set X-Content-Type-Options nosniff
Header set X-XSS-Protection "1; mode=block"
Header set Referrer-Policy: strict-origin-when-cross-origin
# The line below is an advanced method for a more secure configuration, please see documentation before usage!
# Introduction: https://scotthelme.co.uk/content-security-policy-an-introduction/
# http://www.heise.de/security/artikel/XSS-Bremse-Content-Security-Policy-1888522.html (German)
# Documentation: https://content-security-policy.com/
# Analysis: https://securityheaders.io/
Header set Content-Security-Policy "default-src 'self'; img-src 'self' http: https: *.gravatar.com; script-src 'self' www.google-analytics.com *.cloudflare.com""
# Allow WordPress Embed
# https://gist.github.com/sergejmueller/3c4351ec29576fb441fe
SetEnvIf Request_URI "/embed/$" IS_embed
Header set X-Frame-Options SAMEORIGIN env=!REDIRECT_IS_embed
#Force secure cookies (uncomment for HTTPS)
Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
#Unset headers revealing versions strings
Header unset X-Powered-By
Header unset X-Pingback
Header unset SERVER
# Filter Request Methods
# See: https://perishablepress.com/disable-trace-and-track-for-better-security/
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|DELETE|TRACK) [NC]
RewriteRule ^(.*)$ - [F,L]
# Strict transport security
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
# Hide Apache info
ServerTokens ProductOnly
ServerSignature Off
# END SECURITY