这样做的好处一个是很友好,另一个是对于你的网站会更安全些,如果没设置,别人在你的网址后随便输入一个路径,会显示404错误,并且会显示你的服务器版本号,服务器配置一目了然,为了避免这种情况,可以设置错误页面。
当出现404错误,即找不到网页时,把访问者导入到一个事先定义好的错误页面。修改 httpd.conf找到:#ErrorDocument 500 "The server made a boo boo."#ErrorDocument 404 /missing.html#ErrorDocument 404 "/cgi-bin/missing_handler.pl"#ErrorDocument 402 xxxxxxxhttpd.conf中的这一部分,#ErrorDocument 404 /missing.html 是显示错误页信息的,去掉前面的#修改为 ErrorDocument 404 /error.htm,其中error.htm为站点根目录下和error目录下的一个错误文件,需要你自己建立。当发生404错误时,进入error.htm页面,可以提示网页没有找到。这样就不可能看到你的服务器软件信息了。也可以设置其它的错误导向的页面,具体http响应错误编号请查阅相关资料。重新启动apache,如果没意外,此时已经安装成功,把静态页面放到站点根目录和error目录下,看能不能成功解析。随便输入一个:http://localhost/abcd.htm,看是不是导向你设置的404错误,即error.htm错误页面.! 百度到这个方法,配置好重启apache之后发现不行。。。找了半天看到Include "conf/extra/httpd-multilang-errordoc.conf"这种类似的语句。在conf/extra/httpd-multilang-errordoc.conf文件里面发现了ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.varErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.varErrorDocument 403 /error/HTTP_FORBIDDEN.html.varErrorDocument 404 /404error.htmlErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.varErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.varErrorDocument 410 /error/HTTP_GONE.html.varErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.varErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.varErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.varErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.varErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.varErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.varErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.varErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.varErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.varErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var原来是被覆盖掉了在这里改掉之后重启apache之后就OK了。。。。我安装的是xampp集成环境