【问题标题】:Restrict access to all files and folders using password but allow access to one url with no password使用密码限制对所有文件和文件夹的访问,但允许在没有密码的情况下访问一个 url
【发布时间】:2014-01-07 00:37:22
【问题描述】:

目标 - 限制对服务器的访问但允许访问

http://devserver/api/api-test

以下内容可以很好地限制用户,但我似乎无法向任何想要在我的 .htaccess 文件中访问 /api/api-test url 的用户授予访问权限。

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /var/www/.htpasswd
Require user pw

// the below does not work I have tried my variations.
<Files "api-test.php">
 Order Deny,Allow
 Allow from All
</Files>

【问题讨论】:

    标签: .htaccess drupal-7 apache2


    【解决方案1】:

    用这个替换你的代码:

    SetEnvIfNoCase Request_URI "/api/api-test" ALLOWED
    
    AuthType Basic
    AuthName "Restricted Area"
    AuthUserFile /var/www/.htpasswd
    Require user pw
    Satisfy    any
    Order      deny,allow
    Deny from  all
    Allow from env=ALLOWED
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-23
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多