Skip to content

Instantly share code, notes, and snippets.

@ianpegg
Created September 16, 2022 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianpegg/3fc5734034f99acccdc662120f353e98 to your computer and use it in GitHub Desktop.
Save ianpegg/3fc5734034f99acccdc662120f353e98 to your computer and use it in GitHub Desktop.
Essential WordPress Apache .htaccess security snippets
# ----------------------------------------------------------------------
# Security: Block access to backup and source files
# ----------------------------------------------------------------------
<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
# ----------------------------------------------------------------------
# Security: Hardening Headers
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
Header set X-Content-Type-Options nosniff
</IfModule>
# ----------------------------------------------------------------------
# Security: Block XMLRPC as it is deprecated
# ----------------------------------------------------------------------
<Files xmlrpc.php>
Order Allow,Deny
Deny from all
</Files>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment