標籤:
這樣做的好處一個是很友好,另一個是對於你的網站會更安全些,如果沒設定,別人在你的網址後隨便輸入一個路徑,會顯示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了。。。。
我安裝的是xamppIntegration Environment
xmapp 404設定