Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I asked this question at stackoverflow but I didn't recvie any solutions so I think the good people at serverfault may be able to help.

All the resources I've read explains how to prevent access to an entire directory based on IP but doesn't explain how to do this for a single file.

This is what is used to protect a directory:

<Limit GET POST PUT>
 order deny,allow
 deny from all
 allow from 123.456.78.910
</Limit>

^ here only the IP 123.456.78.910 will have access to the directory in which that rule is placed. But the question again is, How to do this for a single file?

Thank you.

share|improve this question
add comment

1 Answer

Wrap the rule in a <Files> block.

<Files filename.html>
   order deny,allow
   deny from all
   allow from 123.456.78.910
</Files>

Also, unless you have a specific need to allow other methods, ditch the <Limit> block. In the setup you showed, it's actually protecting less.

share|improve this answer
add comment

Your Answer

 
discard

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