Prevent viewing of file with htaccess – A Comprehensive guide to htaccess
Prevent viewing of file with htaccess; For some situation, we need to block a file or a site file. I will explain this with an example. Consider we are getting a continues WordPress login attack to the server or a particular site and keep changing the source IP (DDoS attack). That means the hacker keeps the attacking the file WordPress file wp-login.php. This attack will slow down the server. One way to block DDoS attack block the public access of the wp-login.php file using htaccess.
Here is the code for that
deny from all
The first line specifies that the file named .htaccess is having this rule applied to it. You could use this for other purposes as well if you get creative enough. If a person trying to see that file would get returned (under most server configurations) a 403 error code.