Apache authentication except localhost

后端 未结 2 1154
孤街浪徒
孤街浪徒 2021-02-07 02:56

I need to apply HTTP auth just in public use of website, but I don\'t apply it on my localhost. This is the .htaccess that I think should work. But it doesn\'t work

2条回答
  •  时光取名叫无心
    2021-02-07 03:33

    In Apache 2.4, allow, deny and satisfy are not used anymore, IP address restriction is also done with require now:

    AuthUserFile /path/to/.htpasswd
    AuthName "Restricted Access"
    AuthType Basic
    Require ip 127.0.0.1
    Require valid-user
    

    If any of the "Require" directives are fulfilled, the request is allowed. If you want to require both, group them in a block.

    For restriction to local access you can use the special syntax Require local instead of Require ip 127.0.0.1

    Read more: http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require

提交回复
热议问题