WordPress Security Headers Every Site Should Send

WP-Sec Team · Sep 05, 2026 · 551 words
WordPress Security Headers Every Site Should Send
Photo: Markus Spiske via Pexels

Understanding WordPress Security Headers

WordPress security headers are essential components of your website's HTTP response. They help protect your site from various vulnerabilities and attacks, such as cross-site scripting (XSS) and clickjacking. By implementing the right security headers, you can significantly enhance your site's defenses and ensure a safer experience for your visitors.

Essential WordPress Security Headers

Here’s a list of the most important WordPress security headers you should consider implementing:

  • Content-Security-Policy (CSP): This header helps prevent XSS attacks by specifying which sources of content are trusted. For example:
Content-Security-Policy: default-src 'self'; img-src 'self' https://trusted.com; script-src 'self' https://trusted.com;
  • X-Content-Type-Options: This header prevents browsers from interpreting files as a different MIME type than what is specified. Use the following:
X-Content-Type-Options: nosniff
  • X-Frame-Options: This header protects your site from clickjacking attacks by controlling whether your site can be embedded in an iframe. Set it like this:
X-Frame-Options: DENY
  • X-XSS-Protection: This header enables the browser's built-in XSS protection. Add it as follows:
X-XSS-Protection: 1; mode=block
  • Strict-Transport-Security (HSTS): This header enforces secure connections to your server. Use it to ensure all traffic is served over HTTPS:
Strict-Transport-Security: max-age=31536000; includeSubDomains
  • Referrer-Policy: This header controls how much referrer information is passed when navigating from your site. A good practice is:
Referrer-Policy: no-referrer-when-downgrade

How to Implement WordPress Security Headers

Implementing these security headers can be done in a few different ways. Here are some methods to consider:

  • Using a Security Plugin: Many WordPress security plugins allow you to easily add security headers without needing to code. Popular options include:
    • Wordfence
    • iThemes Security
    • All In One WP Security & Firewall
  • Editing the .htaccess File: If you are comfortable with code, you can add headers directly to your .htaccess file. Here’s how:
    1. Access your website’s files via FTP or your hosting control panel.
    2. Locate the .htaccess file in the root directory of your WordPress installation.
    3. Add the header lines mentioned above at the end of the file.
    4. Save the changes and test your site.
  • Configuring Your Web Server: If you are using a web server like Nginx, you can add headers in your server configuration file. For example:
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options DENY;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

Testing Your Security Headers

After implementing the security headers, it’s crucial to test them to ensure they are working correctly. You can use online tools such as:

These tools will analyze your site and provide feedback on the security headers being sent, along with suggestions for improvement.

Regular Audits and Updates

Implementing security headers is just one part of maintaining a secure WordPress site. Regularly auditing your site for vulnerabilities is essential. Consider using a WordPress vulnerability scanner to check for outdated plugins and known CVEs. This proactive approach helps you stay ahead of potential threats.

Conclusion

By implementing the right WordPress security headers, you can significantly reduce the risk of attacks on your site. Coupled with regular security audits and updates, these measures will help keep your site secure and maintain your online reputation.

Where to start

If you’re unsure about your site's security status or need assistance in implementing these security headers, consider getting a comprehensive online presence audit. This will help identify vulnerabilities and ensure your site is protected against potential threats.

Want this done for you — automatically?

The WP-Sec WordPress audit checks everything in this article against your actual business: Google reputation, local rankings, website health, conversion readiness and AI search visibility — ranked by revenue impact.

Get my audit — $40 →