404页显示页面的名称

我的网站很棒, 运行Ubuntu和Apache2的Google Cloud Platform VM。 那么,除了一件事, 我无法获得404页面的工作。 我跟着几个导游,设法做了一些非常愚蠢的事情。

这是404的结果:

404错误文档

这是实际的404文档( /404.html的内容):

 <!doctype html> <head> <title>404</title> </head> <body> <h1>404 :(</h1> This page doesn't exist. Sorry! <br><br> You can <button onclick="history.back();">Go back</button>, jump to the <a href="/">Site root</a>, or the <a href="/kcp">KCP root</a>. </body> 

我已经删除了每个.htaccess文件和每个ErrorDocument ...行,我可以find,试图恢复默认行为。

更新:发现错误的行,谢谢!

您看到的响应与定义如下的404 ErrorDocument一致:

 ErrorDocument 404 "404.html" 

通过在引号中围绕第二个参数,可以将“错误文档”定义为一个简单的string。 服务器仍然以404 HTTP状态码进行响应。

而它应该是这样的:

 ErrorDocument 404 /404.html 

我已经删除了每个.htaccess文件和每个ErrorDocument ...行,我可以find

如果你有访问服务器configuration,那么服务器configuration将是一个更通常的地方。 在这种情况下,您需要重新启动服务器才能使更改生效。

或者,响应caching在服务器端/代理?


更新:如果你不能find设置的位置,那么(作为一个解决方法)你应该能够在.htaccess正确地重新定义ErrorDocument ,并且这应该覆盖父.htaccess文件或服务器configuration中的任何设置。 (这是提供AllowOverride FileInfo – 或更高版本 – 在服务器configuration中设置,允许首先在.htaccess中设置ErrorDocument 。)