开发者

Allow directory listing only for a IP

开发者 https://www.devze.com 2023-03-26 20:11 出处:网络
I\'ve activated directory listing with this line in the .htaccess: Options +Indexes How can I limit this to only one IP address with having access to all files开发者_JAVA技巧/directories for everyo

I've activated directory listing with this line in the .htaccess:

Options +Indexes

How can I limit this to only one IP address with having access to all files开发者_JAVA技巧/directories for everyone (every IP)?


Not tested:

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

This way the Options +Indexes will be valid only for IP 195.112.15.4


I know this is an old thread but as I have just found something that seems to work, I've decided to share it here.

Adding this seems to do the trick:

<Files .>
   Order Deny,Allow
   Deny From All
   Allow From 195.112.15.4
</Files>


This is what I got working for me, this is the .htaccess inside the folder I don't want everyone to be able to list, but if I give them a link to a file inside it, I want anyone (all) to be able to download the link.

allow from all
Options -Indexes

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

<Files .>
   Order Deny,Allow
   Deny From All
   Allow From xx.xx.xx.xx
   # put the IP you want to allow indexing for above here
   Options +Indexes
</Files>


tested
supposing "index.html" is the one configured as your DirectoryIndex, and XX.XX.XX.XX is your IP address, simple put these lines:

<FilesMatch "index.html"> 
    Order deny,allow 
    Deny from all 
    allow from  XX.XX.XX.XX  
</FilesMatch>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号