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

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

问题描述

下面是.htaccess文件的相关部分:

 的AuthUserFile /var/www/mywebsite/.htpasswd
目录AuthGroupFile的/ dev / null的
AuthName指令保护
AuthType选项基本
需要有效的用户400的ErrorDocument /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
500的ErrorDocument /var/www/errors/index.html

Docuement根设置到/ var / WWW / mywebsite /网络,这是许多虚拟主机的。我可以导航到index.html页面。

所有我看到的是通用的Apache 381页,什么想法。

编辑:这是我的浏览器的错误信息:


  

需要授权


  
  

此服务器无法验证您
  被授权访问文档
  请求。无论您所提供的
  错误的凭据(例如,坏
  密码),或者你的浏览器不
  理解如何提供
  所需的凭据。


  
  

此外,401授权
  遇到需要错误,
  试图使用ErrorDocument来
  处理该请求。阿帕奇/ 2.2.9
  (Debian的)PHP / 5.2.6-1 + lenny8与
  在www.dirbe.com了Suhosin,补丁服务器
  端口80



解决方案

请确保在/ var / WWW /错误是由Apache用户可读的,包括这Apache配置:

 <目录/ var / WWW /错误>
  为了允许,拒绝
  所有允许
< /目录>

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

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

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

EDIT: This is the error message in my browser:

Authorization Required

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.

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

解决方案

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天全站免登陆