Apache服務器設置404錯誤頁 這樣做的好處一個是很友好,另一個是對于你的網站會更安全些,如果沒設置,別人在你的網址后隨便輸入一個路徑,會顯示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 xxxxxxx httpd.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.var ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var ErrorDocument 404 /404error.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 原來是被覆蓋掉了 在這里改掉之后重啟apache之后就OK了。。。。
|