Htaccess,允许ip,拒绝ip并提示其他

时间:2015-01-27 11:56:36

标签: apache .htaccess

我有一个不需要登录提示的ip列表...我有一个禁止ip的列表(没有提示juste拒绝访问)但是我需要提示所有其他ip ...

我试过了:

AuthType Basic
AuthName "Restricted Area"
AuthUserFile .htpasswd
Require valid-user

Order Deny,Allow
Deny from all

Allow from 82.xxx.xxx.xxx

Deny from 109.xxx.xxx.xxx
Deny from 109.xxx.xxx.xxx
Deny from 109.xxx.xxx.xxx

Satisfy any

但是如果你接受了禁止的ip,你会有提示......如果你改变满意度(“满足所有”),你就会在允许的IP上提示......

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的技巧:

Order Allow,Deny
Allow from all

Deny from 109.xxx.xxx.xxx
Deny from 109.xxx.xxx.xxx
Deny from 109.xxx.xxx.xxx

<IfModule mod_rewrite.c>
    RewriteEngine On

    <If "%{REMOTE_ADDR} != '82.xxx.xxx.xxx'">
        AuthType Basic
        AuthName "restricted area"
        AuthUserFile /var/www/.htpasswd
        require valid-user
    </If>
</IfModule>
Satisfy All

但是此解决方案仅适用于apache&gt; = 2.4,因为旧版本不支持IF语句....

你有没有其他解决方案apache 2.2 ??