tags:

views:

54

answers:

1

Hi,

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.

A: 

You could use this :

<Files foo.html>
    Order deny, allow
    Deny from all
    Allow from 123.456.78.910
</Files>

By the way, do not use <Limit GET POST PUT> to deny access to files, it is a big security hole with most Apache configurations.

Pierre Bourdon
Sorry delroth, but your code just causes an internal server error.
Qasim
Oh, sorry, it's "Files" and not "File". Edited my answer.
Pierre Bourdon