允许用户或 ips 使用 apache 访问

Allow either users OR ips to access using apache

我在 .htpasswd 中有用户,在 .htaccess 中有允许的 IP 我想允许 user/password(对于不在 .htaccss 中的 IP)或 IP 访问(无需授权)。

我用这些行编辑了 httpd 中的目录部分 但它要求 user/password 允许的 IP 和不在文件中的 IP 不要求进行身份验证。

<Directory xxx>
    AllowOverride All
    Options Indexes FollowSymLinks
    AuthName "Authentication required!"
    AuthType Basic
    AuthUserFile <my path>/.htpasswd
    <RequireAny>
        Require ip 127.0.0.1
        Require valid-user
    </RequireAny>
</Directory>

这些配置对我有用

  AllowOverride All
  AuthType Basic
  AuthName "Authentication Required"
  AuthUserFile "/my path/.htpasswd"
  Require valid-user
  satisfy any
  deny from all
  allow from x.x.x.x