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.
Posted: 17:03 on Wednesday 8 December 2004 under Apache, Website development.
Comments: 3
RSS (for comments on this post only)Share This
Comments
Comment from Jerald
Time: Saturday 26 July 2008, 12:13
I have used your code and I was now able to protect certain files from the viewer like classes file and my .htaccess file.
Thanks Alot!
Comment from nenja
Time: Saturday 11 October 2008, 22:43
Where do I put that little snippet of code? In the .htaccess?

Write a comment
Please note the rules for comments and the privacy policy and data protection notice. I'm sorry but, because not everyone sticks to the rules, I've had to implement some spam prevention measures - if you're experiencing difficulties leaving a comment, please let me know.