越来越"需与QUOT认证;申请时/代替的index.php [英] getting "authentication required" when requesting / instead of /index.php

查看:196
本文介绍了越来越"需与QUOT认证;申请时/代替的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的服务器我有以下.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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆