mod_rewrite
文件中的
.htaccess
规则的URL。我的设置是,我所有的URL都可以通过我的index.php
文件,并且从那里找到了相关的代码并运行了。我尝试添加我想排除的URL(
/businesses/upload_logo
),就像我所做的那样,但仍然需要身份验证。这就是我目前拥有的:
...
<Location />
SetEnvIf Request_URI "/businesses/upload_logo" noauth=1
SetEnvIf Request_URI "/api/.*" noauth=1
AuthType Basic
AuthName "Private"
AuthUserFile ****
Require valid-user
Order deny,allow
Satisfy any
Deny from all
Allow from env=noauth
</Location>
....
我发现了与我的Herey&
here相似的问题,但是答案只给了我我已经在尝试的东西。 我也想到了其他解决方案,但这将是最后的解决方案。我想看看是否有可能像我目前这样做的方式:
设置我的php代码中的基本验证 目前很麻烦
在我的
.htaccess
SetEnvIf HOST ...
规则:
mod_rewrite
...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [L,QSA]
对于我来说,类似魅力的事情是:
Allow from env=REDIRECT_noauth
这对我有用:
<location />
SetEnvIf Request_URI "/businesses/upload_logo" REDIRECT_noauth=1
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/httpd/passwords/passwords
Order Deny,Allow
Satisfy any
Deny from all
Allow from env=REDIRECT_noauth
Require user yournickname
</location>
除非您的配置中的其他地方有冲突的指令,否则您应该使用的是您所提供的。 我已经做了类似的工作设置,只是我已经使用了文件系统路径而不是uri
我在这里添加它,希望您可能会发现它有用SetEnvIf Host domain.com block_access
AuthUserFile /path/to/.htpasswd
AuthName 'Login'
AuthType Basic
Require valid-user
Order Allow,Deny
Allow from all
Deny from env=block_access
Satisfy Any
<If "%{THE_REQUEST} =~ m#^GET /api/always/available#">
Allow from All
Satisfy Any
</If>