How to deny access to a file using htaccess

Sometimes we need to block the web access to specific files. This can be achieved by configuring htaccess rules as following.

For Apache 2.2,

<Files "file">  
  Order Allow,Deny
  Deny from all

For Apache 2.4+,

<Files "file">  
  Require all denied

Here we need to replace file with the name of the file that we need to block the web access.

Leave a Reply

Your email address will not be published. Required fields are marked *