2015-06-30 14 views

Odpowiedz

9

Jest to możliwe z <If> Expression.

To jest Twój vhost/conf:

<VirtualHost *:80> 
     DocumentRoot /var/www/html 

     Options -Indexes  # disable listing 
     <If "%{REMOTE_ADDR} == '10.0.0.5'"> 
      Options +Indexes # enable listing if ip matches 
     </If> 
</VirtualHost> 

<Directory /var/www/html> 
     Require all granted 
</Directory> 

przetestowane z Ubuntu Server i Windows z Apache 2.4 - niestety to nie będzie działać ze starszymi wersjami Apache.


Dla zakresów IP możliwe jest użycie innego sposobu, aby sprawdzić IP:

<If "%{REMOTE_ADDR} -ipmatch '10.0.0.0/8'"> 

lub szybszym sposobem jest z -R:

<If "-R '192.168.0.0/16' || -R '10.0.248.0/24'"> 
+0

Dzięki za tą nagrodę i za wskazówkę z '-R' - doktorzy mówią, że jest to również bardziej efektywne. – CodeBrauer

Powiązane problemy