ErrorDocument works correctly when there is really no page. Personally, the transfer of the header also worked correctly for me, and in general, it should work correctly if the server and php are correctly configured. But at the same time, apache is not going to do any redirection in the second paragraph, because it doesn’t see the point - ErrorDocument works precisely because of the actual absence of a page or the absence of redirection rules for the requested address, when the page simply gives 404 code her business. Further it is meant that it is necessary to deduce most necessary.
That is, either to completely enclose a page that lies along the path /views/error.html with something like this:
if (we_have_404) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); include "/views/error.html"; exit(); }
in order to minimize the duplicate code on the site, or display something of their own.