2012-10-06 66 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