Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Let me just say that doing this sort of thing with .htaccess files has never been a strong point for me. Let's say that I have a directory in my web root: /dir/data Within that directory let's say that I have a file called data.txt I need to completely restrict access to data.txt (or the whole data directory). The only things that I want to be able to access the data.txt is a script located at /dir/data.php I also use scp in a shell file on another server to update the data.txt file, hence this shell file will have to be allowed to access the directory and file as well. I for the life of me can't seem to find what I need on Google (though I know it's there somewhere). I really appreciate any help.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You could deny all text file access...

<Files *.txt>
Order deny,allow
Deny from All 
</Files>
share|improve this answer
    
That's exactly what they are looking for –  John Conde Nov 10 '10 at 21:09
    
Huh, it's too simple. Ha, I figured it would end up being a simple solution that I was making out to be far more difficult than it needed to be. Thanks! –  Adam Thompson Nov 10 '10 at 21:09

Another option, perhaps preferred, is to move that directory (or just the file) outside of your web root. That way its impossible to get to it via web browser but it is still available to your scripts.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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