1

我想保护我仍在处理的某些文件不受不受保护的访问,所以我猜想,我只是在他们的文件名中使用一个标识符,如“_temp”,并通过 htaccess 保护所有 url 匹配。

将此与 FileMatch 一起用于文件很好,但我也确实已经编写了一些 htaccess 行,因此 GET-site-parameter 成为一个子域。子域不是文件,所以没有 FileMatch。我还注意到,_ 似乎对子域无效^^ 所以“ 。temp。 ”应该足够了......

然后我使用了 SetEnvIf,但它在所有情况下都不能保护任何东西或所有东西。你能告诉我我做错了什么吗?

SetEnvIf HOST .*temp.* notallowed
SetEnvIf Request_URI .*temp.* notallowed

AuthType Basic
AuthName "Under construction"
AuthUserFile /home/auth/.htpasswd
AuthGroupFile /home/auth/.htgroup

Order Deny,Allow
Satisfy any
Deny from env=notallowed
Require user qwerty
Allow from all

这应该在 huitemp.mysite.de 、 hui.mysite.de/huitemp.php 和 hui.mysite.de/?site=huitemp 上给我一个密码提示,但在 hui.mysite.de 上没有。

PS,我还发现了这篇文章: Passwordprotect a cname subdomain with .htaccess? 但这与我想做的相反,顶级示例对我来说并不真正适用(正如作者已经说过的那样)。

4

1 回答 1

1

尝试先从所有人拒绝,然后从 !notallowed 允许:

SetEnvIf HOST .*temp.* notallowed=true
SetEnvIf Request_URI .*temp.* notallowed=true

AuthType Basic
AuthName "Under construction"
AuthUserFile /home/auth/.htpasswd
AuthGroupFile /home/auth/.htgroup

Order Deny,Allow
Deny from all
Satisfy any
Require user qwerty
Allow from env=!notallowed
于 2013-05-17T15:56:34.403 回答