Link to home
Start Free TrialLog in
Avatar of qwertq
qwertq

asked on

deny direcotory listing, allow by ip

i want to deny directory listing via htaccess, but allot a certain ip (mine) to see it.
Avatar of ahoffmann
ahoffmann
Flag of Germany image

something like:

<Location /directory>
    Options       +Indexes
    <LIMITExcept HEAD GET>
        Order           deny,allow
        Deny from       all
        Allow from localhost
    </LIMIT>
</Location>
Avatar of qwertq
qwertq

ASKER

hm, that seems to block access to the files inside.
i want the files contained in this directory to be visible, i only want to block dir listing
Avatar of alimu
how about creating a second virtual directory that points to the same spot, allow your ip only and give it directory browse rights?
AJ.
Avatar of qwertq

ASKER

can this not be done simply with htaccess?
alternate solution if you can't get it going with htaccess (not really an answer to the question - sorry about that)
you need a second <Location> one which has
  Option -Indexes
has no LIMITs, and one with
  Option +Indexes
has password protected LIMITs
Avatar of qwertq

ASKER

thank you a hoffman, but i have no idea what you are talking about
<Location /dir-no-index>
    Options       -Indexes
</Location>
<Location /dir-with-index-but-protected>
    Options       +Indexes
    <LIMITExcept HEAD GET>
        Order           deny,allow
        Deny from       all
        Allow from localhost
    </LIMIT>
</Location>

if you call in your URL /dir-no-index you get a 404 not found ('cause index is off)
if you call in your URL /dir-with-index-but-protected you get a 401 not authorized except if caled from localhost
you may also add your public IP, or even network masks here

   Allow from localhost your.FQDN
Avatar of qwertq

ASKER

i was never able to get a working example of this problem.

i want ONE directory which will deny dir listing to it and all child directories to anyone except a certain ip. it needs to allow the website to use the contents of the dir as well.
and what's wrong with my last suggestion?
"not working" is no valid answer
Avatar of qwertq

ASKER

"if you call in your URL /dir-no-index you get a 404 not found ('cause index is off)
if you call in your URL /dir-with-index-but-protected you"

this is not one location, and will not work. my source would reflect "dir-with-index-but-protected you/"
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial