免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2902 | 回复: 5
打印 上一主题 下一主题

[Web] 怎样自定义apache下error-404错误? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-05-28 22:53 |只看该作者 |倒序浏览
在论坛也找帖子看了,修改了还是不行,一访问不存在的页面就会出现windows-IE的404错误页面,而访问不存在的目录时则会出现apache默认的403error
在www根目录下建立的有error/error.html,
以下节选httpd(win32):
................
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
ErrorDocument 404 /error.php
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# Putting this all together, we can internationalize error responses.
#
# We use Alias to redirect any /error/HTTP_<error>;.html.var response to
# our collection of by-error message multi-language collections.  We use
# includes to substitute the appropriate text.
#
# You can modify the messages' appearance without changing any of the
# default HTTP_<error>;.html.var files by adding the line:
#
#   Alias /error/include/ "/your/include/path/"
#
# which allows you to create your own set of files by starting with the
# @exp_errordir@/include/ files and copying them to /your/include/path/,
# even on a per-VirtualHost basis.  The default include files will display
# your Apache version number and your ServerAdmin email address regardless
# of the setting of ServerSignature.
#
# The internationalized error documents require mod_alias, mod_include
# and mod_negotiation.  To activate them, uncomment the following 30 lines.

#    Alias /error/ "/error/"
#
#    <Directory "@exp_errordir@">;
#        AllowOverride None
#        Options IncludesNoExec
#        AddOutputFilter Includes html
#        AddHandler type-map var
#        Order allow,deny
#        Allow from all
#        LanguagePriority en cs de es fr it nl sv pt-br ro
#        ForceLanguagePriority Prefer Fallback
#    </Directory>;
#
#    ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
#    ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
#    ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
       ErrorDocument 404  /error/error.html
#    ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
#    ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
#    ErrorDocument 410 /error/HTTP_GONE.html.var
#    ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
#    ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
#    ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
#    ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
#    ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
#    ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
#    ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
#    ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
#    ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
#    ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var



#
# The following directives modify normal HTTP response behavior to
# handle known problems with browser implementations.
#

论坛徽章:
0
2 [报告]
发表于 2004-05-29 00:59 |只看该作者

怎样自定义apache下error-404错误?

就是你所规定的404自定义错误文件不能小于512字节,否则就不能打开自定义页面

论坛徽章:
0
3 [报告]
发表于 2004-05-30 17:29 |只看该作者

怎样自定义apache下error-404错误?

老大~
您的设置是
  1. ErrorDocument 404 /error.php
复制代码


就是说您的 在你的网站的根目录下面要有 error.php 这个文档。

论坛徽章:
0
4 [报告]
发表于 2004-05-30 18:50 |只看该作者

怎样自定义apache下error-404错误?

[quote]原帖由 "jackieyuan"]??error.php 这个文档。[/quote 发表:

假如你设置ErrorDocument 404 /error.php
那么error.php就应该放在根目录下
这个路径也是可以定义的
关键的一点是这个error页面文件不能小于512字节

论坛徽章:
0
5 [报告]
发表于 2004-05-30 20:21 |只看该作者

怎样自定义apache下error-404错误?

原帖由 "cac" 发表:

假如你设置ErrorDocument 404 /error.php
那么error.php就应该放在根目录下
这个路径也是可以定义的
关键的一点是这个error页面文件不能小于512字节


收到! 谢谢!   

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
6 [报告]
发表于 2004-06-01 15:50 |只看该作者

怎样自定义apache下error-404错误?

这个抱错文件和目录最好在你的发布目录中。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP