|
Apache服務(wù)器設(shè)置404錯(cuò)誤頁(yè) 這樣做的好處一個(gè)是很友好,另一個(gè)是對(duì)于你的網(wǎng)站會(huì)更安全些,如果沒設(shè)置,別人在你的網(wǎng)址后隨便輸入一個(gè)路徑,會(huì)顯示404錯(cuò)誤,并且會(huì)顯示你的服務(wù)器版本號(hào),服務(wù)器配置一目了然,為了避免這種情況,可以設(shè)置錯(cuò)誤頁(yè)面。 當(dāng)出現(xiàn)404錯(cuò)誤,即找不到網(wǎng)頁(yè)時(shí),把訪問者導(dǎo)入到一個(gè)事先定義好的錯(cuò)誤頁(yè)面。 修改 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 是顯示錯(cuò)誤頁(yè)信息的,去掉前面的# 修改為 ErrorDocument 404 /error.htm, 其中error.htm為站點(diǎn)根目錄下和error目錄下的一個(gè)錯(cuò)誤文件,需要你自己建立。當(dāng)發(fā)生404錯(cuò)誤時(shí),進(jìn)入error.htm頁(yè)面,可以提示網(wǎng)頁(yè)沒有找到。這樣就不可能看到你的服務(wù)器軟件信息了。也可以設(shè)置其它的錯(cuò)誤導(dǎo)向的頁(yè)面,具體http響應(yīng)錯(cuò)誤編號(hào)請(qǐng)查閱相關(guān)資料。 重新啟動(dòng)apache,如果沒意外,此時(shí)已經(jīng)安裝成功,把靜態(tài)頁(yè)面放到站點(diǎn)根目錄和error目錄下,看能不能成功解析。隨便輸入一個(gè):http://localhost/abcd.htm,看是不是導(dǎo)向你設(shè)置的404錯(cuò)誤,即error.htm錯(cuò)誤頁(yè)面.! 百度到這個(gè)方法,配置好重啟apache之后發(fā)現(xiàn)不行。。。 找了半天看到Include "conf/extra/httpd-multilang-errordoc.conf"這種類似的語(yǔ)句。 在conf/extra/httpd-multilang-errordoc.conf文件里面發(fā)現(xiàn)了 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 原來(lái)是被覆蓋掉了 在這里改掉之后重啟apache之后就OK了。。。。
|