1

My website works great; Google Cloud Platform VM running Ubuntu and Apache2. Well, except for one thing; I can't get 404 pages to work. I followed several guides and managed to do something really dumb.

This is the result of a 404:

404 Error Document

This is the actual 404 document (the contents of /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>

I've deleted every .htaccess file and every ErrorDocument ... line I can find, trying to restore the default behavior.

UPDATE: Found the errant line, thanks!

1 Answers1

2

The response you are seeing is consistent with having defined the 404 ErrorDocument like this:

ErrorDocument 404 "404.html"

By surrounding the 2nd argument in quotes you define the "error document" as a simple string. The server is still responding with a 404 HTTP status code.

Whereas it should be something like this:

ErrorDocument 404 /404.html

I've deleted every .htaccess file and every ErrorDocument ... line I can find

If you have access to the server config, then the server config would be a more usual place for this. In which case, you would need to restart your server for any changes to take effect.

Or, the response is cached server-side / proxy?


UPDATE: If you can't find where this is being set, then (as a workaround) you should be able to redefine the ErrorDocument correctly in .htaccess and this should override any setting in parent .htaccess files or the server config. (This is providing AllowOverride FileInfo - or greater - is set in the server config, permitting the setting of ErrorDocument in .htaccess in the first place.)

MrWhite
  • 11,643
  • 4
  • 25
  • 40
  • Which server config file do you want me to look at? – SIGSTACKFAULT Oct 12 '17 at 14:59
  • Which config files have you changed? :) The main config file is often called `httpd.conf` (or `apache2.conf`, or _something else_). You might also have separate `Include` files that are included in the main config. You might also have a separate config file for your virtual hosts (or even a separate file for each virtual host)? – MrWhite Oct 12 '17 at 15:13
  • Note that if you cannot find where this is defined then you should be able to define the `ErrorDocument` again in `.htaccess` to override this. I've updated my answer. – MrWhite Oct 12 '17 at 19:24