Since order allow,deny
is deprecated in 2.4 I wanted to rewrite the rules in my .htaccess file to use the new rules. Previously I was using:
<files wp-config.php>
order allow,deny
deny from all
</files>
Which I've rewritten to:
<FilesMatch "wp-config.php">
Require all denied
</FilesMatch>
How do I confirm that my method is actually working? I'm not certain how hackers might gain access to this file so I don't know how to test it.
Since order allow,deny
is deprecated in 2.4 I wanted to rewrite the rules in my .htaccess file to use the new rules. Previously I was using:
<files wp-config.php>
order allow,deny
deny from all
</files>
Which I've rewritten to:
<FilesMatch "wp-config.php">
Require all denied
</FilesMatch>
How do I confirm that my method is actually working? I'm not certain how hackers might gain access to this file so I don't know how to test it.
Share Improve this question edited Nov 4, 2018 at 12:56 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 2, 2018 at 14:43 jarrodwhitleyjarrodwhitley 1231 silver badge10 bronze badges 3 |2 Answers
Reset to default 1The old method works for me, and any requests result in a 403 status response instead of execution of the php script. I've not checked your 2nd method, but if it works it will similarly respond with 403 denied/forbidden.
To test you simply have to insert the URL of your "wp-config.php" in the address bar of your browser e.g. http://example/wp-config.php . Depending on browser and/or sites custom 403 settings your browser will display "forbidden", "access denied" etc.
Note you can also move wp-config.php one directory up from where Wordpress installed it - and if this is then above Webroot/public_html it will no longer be "directly" accessible by hackers. More on this here Is moving wp-config outside the web root really beneficial?
I discovered that by looking at my server's error logs I could see where the server denied permission to me when I attempted to visit http://example/wp-config.php
It looked like this:
[Fri Nov 02 17:52:22.222222 2018] [authz_core:error] [pid 222] [client 22.222.222.222:22222] AH01630: client denied by server configuration: /nas/wp/www/sites/example/wp-config.php
Allow and Order
was written by someone else before I started working here. All I know is that hackers are able to (somehow) gain access to an unprotected file. I've tried researching how they do it, but I'm coming up with nothing. – jarrodwhitley Commented Nov 2, 2018 at 14:59