Reputation: 4546
I am trying to secure my wordpress site through htaccess - By blocking php files from folders.
Example:
So Far:
Deny wp-config.php
<files wp-config.php>
order allow,deny
deny from all
</files>
Run only certain files (but i cant get directory to work on this level)
Order deny,allow
Deny from all
<Files ~ ".(xml|css|jpe?g|png|gif|js)$">
Allow from all
</Files>
Upvotes: 2
Views: 1488
Reputation: 784868
You cannot match directories using Files
directive.
Have these 2 rules as your very first rules in main WP .htaccess:
RewriteEngine On
RewriteRule ^/?wp-content/.+?\.php - [NC,F]
RewriteCond %{REQUEST_URI} !^/(index|wp.+?)\.php [NC]
RewriteRule ^/?[^./]+\.php - [NC,F]
Don't forget to remove all the Files
blocks.
Upvotes: 2