简体   繁体   中英

Htaccess, allow ip, deny ip and prompt for other

I have a list of ip which doesn't require login prompt ... I have a list of banned ip ( no prompt juste deny access ) But i need a prompt for all others ip ...

I tried this :

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

But if you come on with a banned ip, you have the prompt ... if you change Satisfy ( "Satisfy all" ) you have the prompt on allowed ip ...

i found a trick for my problem :

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

But this solution work only on apache >= 2.4 because IF statement isn't supported by older version ....

do you have any others solutions for apache 2.2 ??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM