htaccess - using password OR ip whitelist

后端 未结 3 1961
盖世英雄少女心
盖世英雄少女心 2021-01-30 08:46

So I want to restrict access to a url. Now if they are coming from a given IP address then they shouldn\'t be prompted for a password. If they are not coming from a givin IP a

3条回答
  •  温柔的废话
    2021-01-30 09:28

    This workes perfect for me:

    AuthType Basic
    AuthName "myserver publicname"
    AuthUserFile "/myserverpath/.htpasswds/public/passwd"
    require ip 100.12.255.233
    require valid-user
    

    Note: Just placed 'require ip' with 'my example ip' before 'require valid-user' and it does the trick. I can log in from my ip without password requested, but if I access from other locations or my mobile devices I need the password.

    To set 'Satisfy any' was NOT GOOD FOR ME (!), because it disabled other .htaccess settings in lower hierarchy of my app and made my site insecure.

提交回复
热议问题