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 am trying to restrict access to viewing Directory Indexes or viewing lists of files in a directory unless your IP is in a whitelist.

I am using Apache web server and an .htaccess file.

So here is what I have so far

Options -Indexes
<Files *>
deny from all
allow from 71.56.134.456
allow from 71.55.104.468
Options +Indexes
</Files>

This partially works. This does restrict directory viewing to everyone unless there IP is listed. The problem is it also restricts non-whitelisted IP's from viewing files as well.

I need to restrict there access from directory lists but not direct file access.

Please help me

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can use "if" directive in apache for flexible configuration and check variable values:

options -Indexes
<If "%{REMOTE_ADDR} == '127.0.0.1'">
    options +Indexes
</If>
share|improve this answer
    
Awesome I have looked everywhere for this –  jasondavis Aug 17 '13 at 17:08

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.