我们有一个a.com
受密码保护的 drupal 网站。不过,我希望所有a.com/api/...
URI 都不是。所以我读过SetEnvIf
:
AuthName "Stage"
AuthType Basic
AuthUserFile ~/.htpasswd
SetEnvIf Request_URI ".*data_sheets.*\.pdf" noauth
SetEnvIf Request_URI "/api/.+" noauth
SetEnvIfNoCase Request_Method OPTIONS noauth
Order Deny,Allow
Deny from all
Require valid-user
Allow from env=noauth
Satisfy Any
不过,/api/foobar
URI 仍然要求输入密码。由于它是一个 Drupal 网站,在 anubhava 的帮助下,我们认为它与 index.php 如何处理请求有关。
如何处理?
编辑
添加
RewriteCond %{REQUEST_URI} ^/api/ [NC]
RewriteRule ^ - [E=noauth]
紧接着
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
没有帮助