Skip to content

Instantly share code, notes, and snippets.

@dipakcg
Last active February 5, 2021 02:35
Show Gist options
  • Save dipakcg/db86bd0d8b79e51d631e98713da0b6c3 to your computer and use it in GitHub Desktop.
Save dipakcg/db86bd0d8b79e51d631e98713da0b6c3 to your computer and use it in GitHub Desktop.
WordPress: Security Headers
# Add the following security headers in the root .htaccess file of WordPress #
# Get A+ Security Headers Score under securityheaders.com #
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.api.twitter.com https://gist.github.com https://syndication.twitter.com https://platform.twitter.com https://js-agent.newrelic.com https://*.nr-data.net https://*.wp.com https://*.gravatar.com https://*.wp.com https://pagead2.googlesyndication.com https://ssl.google-analytics.com https://connect.facebook.net https://www.google-analytics.com https://cdnjs.cloudflare.com https://ajax.cloudflare.com; img-src 'self' data: https://pbs.twimg.com https://platform.twitter.com https://syndication.twitter.com https://dashboard.wordpress.com https://s-ssl.wordpress.com https://dashboard.google.com https://wordpress.org https://*.w.org https://*.gravatar.com https://*.wp.com https://ssl.google-analytics.com https://s-static.ak.facebook.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline' https://assets-cdn.github.com https://platform.twitter.com https://*.wp.com https://*.gravatar.com https://fonts.googleapis.com; font-src 'self' data: https://s0.wp.com https://fonts.gstatic.com https://themes.googleusercontent.com; frame-src 'self' https://syndication.twitter.com https://platform.twitter.com https://*.cloudfront.net https://*.wp.com https://*.doubleclick.net https://www.facebook.com https://s-static.ak.facebook.com; object-src 'none';"
Header set X-Content-Type-Options nosniff
Header always set X-XSS-Protection "1; mode=block"
Header always set Expect-CT "max-age=604800, enforce"
Header set Referrer-Policy "strict-origin"
Header always append X-Frame-Options SAMEORIGIN
Header always set Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=();"
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment