3

Preferably using .htaccess files, though .conf files are an option, is there any way to stop Apache serving certain filetypes?

For example, .db shouldn't be served for obvious reason (privacy and whatnot, etc.), so could I make them show as a 404 but still have them available for my CGI scripts?

Putting these sensitive files in a directory other than /public_HTML/ is also an option, though I like having them in the same directory as the scripts for ease of use.

Cheers

6

I would have said that placing these sensitive files above the document root would be preferable. And perhaps easier to manage if they are all contained in a particular directory, however...

Using .htaccess to prevent access to all .db and .exe files and return a 403 - Forbidden.

<Files ~ "\.(db|exe)$">
Deny from all
</Files>

Unless you have a specific requirement, I would have thought a 403 would be better than a 404 in this instance, and this would seem more natural for Apache. To return a 404 here would require additional code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.