Drupal sites have two clean paths for security headers: .htaccess for static headers everyone can edit, or the Security Kit (seckit) module for fine-grained, configurable headers with CSP report-uri support. This guide covers every fix our Security Audit raises on Drupal: HTTP security headers via either path, modern TLS at the server level, and publishing security.txt. Tested against Drupal 10.3. For WordPress, see the WordPress variant; for the full finding catalogue, see Security Audit Fixes.
.htaccess is simpler and faster. Security Kit is more powerful (CSP reporting, dynamic policies, per-content-type rules). For most sites, start with .htaccess. Move to Security Kit if you need CSP report-uri to identify policy violations.
Drupal's default .htaccess in the docroot already has security comments — extend it.
.htaccess. Open it with your preferred editor.<IfModule mod_headers.c> block (Drupal ships with X-Content-Type-Options already). Add the others: <IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" Header always set X-Frame-Options "SAMEORIGIN" Header always set X-Content-Type-Options "nosniff" Header always set Referrer-Policy "strict-origin-when-cross-origin" Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()" Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; frame-ancestors 'self'" </IfModule>
For sites with complex content (third-party embeds, CDN-hosted assets, frequent script changes), Security Kit gives you a Drupal admin UI plus CSP report-uri support.
composer require drupal/seckit drush en seckit -y
/admin/config/system/seckit). Each tab (CSRF, XSS, SSL/TLS, Various) maps to specific headers. Configure each section, save.curl -sI https://yourdomain.com/ | grep -iE "strict-transport|x-frame|x-content|referrer|permissions|content-security"All six should appear. Re-run the Security Audit for full verification.
Verify every header, TLS protocol and security.txt with a fresh scan.
Run Security Audit →