问题描述
在我的服务器我有以下.htaccess文件:
On my server I have the following .htaccess file:
DirectoryIndex index.php
AuthType Basic
AuthName "Password Required"
AuthUserFile /var/www/webinterface/.htpasswd
Options +FollowSymLinks
Require valid-user
<Files index.php>
Satisfy any
Allow from *
</Files>
如果我请求URLIP地址/ index.php文件,一切工作正常,我得到的index.php文件显示,无身份验证提示。但是只要我要求IP地址/浏览器问我要我的凭据。
If I request the URL "IP-ADDRESS/index.php", everything works fine, I get the index.php displayed without an authentication prompt. However as soon as I request "IP-ADDRESS/" the browser asks me for my credentials.
为什么会出现这种情况?我在想什么?
Why is this the case? What am I missing?
推荐答案
尝试更换模块使用mod_setenvif检查,而不是使用请求URI &LT;文件&GT;
。该的mod_auth *模块有precedence超过mod_dir所以从映射 /
到的index.php
不直到发生在auth发生之后。 Mod_setenvif将在auth之前发生。尝试:
Try replacing the block to use mod_setenvif to check the request URI instead of using <Files>
. The mod_auth* modules has precedence over mod_dir so the mapping from /
to /index.php
doesn't happen until after the auth takes place. Mod_setenvif will occur before the auth. Try:
SetEnvIf Request_URI "^/$" allow=yes
SetEnvIf Request_URI "^/index.php$" allow=yes
AuthType Basic
AuthName "Password Required"
AuthUserFile /var/www/webinterface/.htpasswd
Options +FollowSymLinks
Order Deny,Allow
Satisfy any
Deny from All
Require valid-user
Allow from env=allow
如果请求的URI正是 /
或的index.php
,变量允许
获取设置。在验证行之后的东西,说要拒绝所有的东西,除了一个有效用户的或的如果变量允许
已设置。
If the requested URI is exactly /
or /index.php
, the variable allow
gets set. The stuff after the Auth lines say to deny everything except a valid user or if the variable allow
has been set.
这篇关于越来越&QUOT;需与QUOT认证;申请时/代替的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!