Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

 order deny,allow
 deny from all
 allow from 123.456.78.910

^ 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

Wrap the rule in a <Files> block.

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

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

Your Answer


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