Deny Access to Any Files

23 Nov, 2009

403 forbidden error, access denied
Question: I have a set of files on my website with the extension .rpc. They are financial files, and I want to make sure that no one can access them from the web. Can i do that?

Answer: On an Apache server, you can do just about anything, and .htaccess files make a lot of that possible. Simply create an .htaccess file or use the one you already have and add something like this:

<Files ~ "^.*\.([Rr][Pp][Cc])">
Order allow,deny
Deny from all
Satisfy All
</Files>

The letters are repeated in lowercase and capital to ensure both are blocked. Simply substitute the letters with whatever extension you want to deny. For example: <Files ~ "^.*\.([Ll][Oo][Gg])"> will deny access to all .log files. It really is that simple.

(0) Comment Categories : Web Hosting, Web servers
Tag: , , , ,