2012-10-06 79 views
21

我知道這個線程已經談了很多網頁和這裏,我嘗試了幾乎所有的方法,但我依然有同樣的問題。獲得404 Not Found錯誤,同時嘗試使用的ErrorDocument

這是我的本地服務器上我的網址(毫安)

http://localhost:8888/hellothere/index.php 

而且我試圖插入一個錯誤的道路帶我到錯誤的頁面,如下圖所示:

http://localhost:8888/hellothere/eiurgiuerib 

相反帶我到錯誤頁面它顯示:

Not Found 

The requested URL /hellothere/eiurgiuerib was not found on this server. 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 

我的404頁面在Error目錄中。而我的.htaccess文件裏面我已經包含了這一點:

ErrorDocument 404 /Error/404.php 
+2

是什麼問題? – StaticVariable

+1

自定義錯誤頁面不起作用。所以我該怎麼做 ? – user1725155

+0

你能顯示你的文件夾架構嗎? – StaticVariable

回答

39

ErrorDocument指令,提供本地URL路徑時,預計的路徑是從DocumentRoot完全合格。在你的情況,這意味着對ErrorDocument實際路徑是

ErrorDocument 404 /hellothere/error/404page.html 
+1

謝謝,它的工作原理。 – user1725155

+0

還有一個想法,如果在我的index.php頁面中,我只是添加下面這行代碼「header(」HTTP/1.0 404 Not Found「);」它不會把我帶到404頁面,爲什麼? – user1725155

+0

@ user1725155你應該看看這篇文章[自定義404不工作(http://stackoverflow.com/questions/5914120/php-header-404-not-working) – StaticVariable

1

在申請本地URL,ErrorDocument指令期望從DocumentRoot的完整路徑。 有,

ErrorDocument 404 /yourfoldernames/errors/404.html