Apache2 中的 401 自定义错误页面 [英] Custom error page in Apache2 for 401

查看:38
本文介绍了Apache2 中的 401 自定义错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 .htaccess 文件的相关部分:

Here's the relevant part of the .htaccess file:

AuthUserFile  /var/www/mywebsite/.htpasswd
AuthGroupFile /dev/null
AuthName  protected
AuthType Basic
Require valid-user

ErrorDocument 400 /var/www/errors/index.html
ErrorDocument 401 /var/www/errors/index.html
ErrorDocument 403 /var/www/errors/index.html
ErrorDocument 404 /var/www/errors/index.html
ErrorDocument 500 /var/www/errors/index.html

文档根目录设置为/var/www/mywebsite/web,它位于许多虚拟主机上.我可以导航到 index.html 页面.

Docuement root is set to /var/www/mywebsite/web, it's on of many vhosts. I can navigate to the index.html page.

我所看到的只是通用的 Apache 401 页面,任何想法.

All I'm seeing is the generic Apache 401 page, any thoughts.

这是我浏览器中的错误消息:

This is the error message in my browser:

需要授权

此服务器无法验证您被授权访问文档要求.要么你提供了错误的凭据(例如,错误的密码),或者您的浏览器没有了解如何提供需要凭据.

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

此外,401 授权遇到必需的错误尝试使用 ErrorDocument 来处理请求.Apache/2.2.9(Debian) PHP/5.2.6-1+lenny8 与www.dirbe.com 上的 Suhosin-Patch 服务器80端口

Additionally, a 401 Authorization Required error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch Server at www.dirbe.com Port 80

推荐答案

确保 apache 用户可以读取/var/www/errors 并将其包含在您的 apache 配置中:

Make sure that /var/www/errors is readable by the apache user and include this in your apache configuration:

<Directory /var/www/errors>
  Order allow,deny
  Allow from all
</Directory>

这篇关于Apache2 中的 401 自定义错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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