目标 - 限制对服务器的访问,但允许访问
http://devserver/api/api-test
以下工作正常可以限制用户,但我似乎无法为任何想要转到我的.htaccess文件中的/ api / api-test网址的用户授予访问权限。
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>
答案 0 :(得分:0)
用以下代码替换您的代码:
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