Skip to content

Instantly share code, notes, and snippets.

@melanyss
Forked from jennimckinnon/.htaccess
Created June 4, 2020 04:07
Show Gist options
  • Save melanyss/3ba19e353979f1e6dc2e7e1745f9f20c to your computer and use it in GitHub Desktop.
Save melanyss/3ba19e353979f1e6dc2e7e1745f9f20c to your computer and use it in GitHub Desktop.
Restrict Direct Access to Plugin and Theme PHP files in WordPress. Source: https://www.acunetix.com/websitesecurity/wordpress-security-top-tips-secure-wordpress-application/
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/
RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment