我们在 ISPConfig 环境中安装了 Apache 2.4。
每个虚拟主机都有一个用于管理目的的目录。我的 .htaccess 看起来如下:
AuthType Basic
AuthName "Administration"
Require valid-user
AuthUserFile /etc/apache2/.htpasswd
现在,当我点击文件夹
http://mysite.tld/admin
时,我会被重定向到网站根目录,而无需登录提示。
但是,当我将 .htaccess 复制到根目录时,我收到登录提示。
当我点击
/admin
时,日志文件包含以下几行:
[Wed Feb 12 12:00:23 2020] [authz_core:debug] mod_authz_core.c(809): AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Wed Feb 12 12:00:23 2020] [authz_core:debug] mod_authz_core.c(809): AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
然后我直接重定向到
/
。
那么重定向的原因可能是什么?
基于Dusan Bajic的评论:
在 Apache vhost 文件(由 ISPConfig 生成)中,有自定义错误页面。 注释/删除 vhost 文件中的这些行:
Alias /error/ "/var/www/mysite.tld/web/error/"
ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 502 /error/502.html
ErrorDocument 503 /error/503.html
解决问题。