Reputation: 1253
I have the same problem as Apache custom 404 page that returns 404 error, but additionally I use html files and no scripting language.
Is there a possibility to configure Apache in a way that it returns the page www.example.com/404.html with a 404 status when requested by the browser?
Upvotes: 0
Views: 1114
Reputation: 1253
I am giving an answer myself, I am not sure if it should be a comment.
I realised that I tried to fix a workaround and not an actual problem. Originally I wanted to show a 404 page using
ErrorDocument 404 /subdirlevel1/404.html
However the error document itself used relative paths and so it only worked when the path of the requested document was in the right subdirectory level. What I mean is the following:
http://example.com/subdirlevel1/nonexisting.html
would produce a proper 404 document, as the path to the css stylesheet was at a proper relative path. However
http://example.com/subdirlevel1/subdirlevel2/nonexisting.html
would not work. I fixed this by using absolute paths in 404.html
Doing it the way I've tried in my question would be bad style, as a request to an existing file with a proper delivery of that file should not result in a 404, but in a 200.
Upvotes: 2