Denying access to certain files on an Apache web server

Under certain circumstances, it may be necessary to deny users access to various files on a web server.

For example, some directives in an Apache .htaccess file may be considered a security risk and so access to the file may be prevented using the following directives:

<files .htaccess>
order deny,allow
deny from all
</files>

The first line limits the directive to the .htaccess file (simply change the filename to limit access to other files), whilst the remaining code sets deny to have precedence over allow, denies access from all users and then terminates the directive.

3 thoughts on “Denying access to certain files on an Apache web server

Leave a Reply