htaccess - using password OR ip whitelist

后端 未结 3 1963
盖世英雄少女心
盖世英雄少女心 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:24

    You can use the Apache "Satisfy" directive.

    Here is an example of using it :

    AuthType Basic
    AuthName "Please Log In"
    AuthUserFile /some/path/.htpasswd
    Require valid-user
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    Satisfy any
    

    Access without password is only allowed from 127.0.0.1.

    Hope this helps.

提交回复
热议问题