How to set up apache to serve no error page content? I don't want the default behavior, blank or custom page. I want return no content except headers, that all browsers must display own native error page. I'm using Apache 2.2.22


I'm fairly sure you can't do this Apache goes to some lengths to be helpful. From the ErrorDocument documentation

In the event of a problem or error, Apache httpd can be configured to do one of four things,

  1. output a simple hardcoded error message

the rest being custom/local/and remote error documents. Later the documentation says

Additionally, the special value default can be used to specify Apache httpd's simple hardcoded message.

So it appears that the default behaviour is to provide a hard coded ErrorDocument and that you can't override that in the way that you want.

  • It's not so good... – kbec May 16 '12 at 8:48
  • Just set the ErrorDocument to a carriage return, ie., ErrorDocument 403 \r – ColtonCat Nov 18 '18 at 8:38
  • I know this is an absolutely old post. But you can modify the apache source to remove the hardcoded error page all at once. but I am not sure if we are allowed to modify the source. – user549144 Jul 20 '20 at 7:04

If your Apache has PHP, Perl or any other dynamic extension capable of HTTP header control, then do create a custom page, which responds with the HTTP header fields you want (e.g. by using the PHP header()), but with no other content such as HTML.

Setting ErrorDocument directive to that custom page should produce the result you want.

Note: I'm aware your question asks how to accomplish the response by setting up Apache to serve no error page content and to not use any custom page. The answer above is valid only if you are not constrained to how the actual problem (i.e. giving a HTTP response containing only HTTP header fields) should be solved. Do you really have the constraint that the actual problem (i.e. desired outcome) must not be solved by involving any custom page?


Have you tried setting empty ErrorDocument directives? Did it work?

ErrorDocument 404 ""


ErrorDocument 404 /path/to/empty/file.html

Apache might be helpful and ignore empty values so you may have to send a space or a <html></html> to prevent it from overriding your values.

It's worth mentioning that browsers don't have error pages for all the different possible error codes. It is the Server's responsibility to provide those pages. When browsers do display their own error pages, it's likely that it will be generic and misleading.

Internet Explorer is unique in thinking it knows better than the server and will override your error pages if they are less than 512 bytes. The others only provide error pages for the situations where the server can't such as a DNS lookup error, a reset connection or a redirect loop. In most browsers, what you will get if you send an empty error document is a blank page.

  • When I use "" the apache reported ErrorDocument takes two arguments, Change responses for HTTP errors on restart. Second solution is just blank page and browser display it either own page. In some random cases my Chrome relly display own errpage, but not always. Maybe if I can change/remove content type it can work, but how? – kbec May 16 '12 at 8:23
  • 2
    In my case an empty string for the ErrorDocument response body was not accepted and gave me an internal server error 500. To make it work, I had to enter at least one character, i.e. ErrorDocument 404 " " or ErrorDocument 404 "\n". In the end I chose to return a minimum of plain text information and went like this: ErrorDocument 404 "404 - NOT FOUND" But if you really want to send zero bytes of response body, you have to go with the empty file solution mentioned in the answer. – Jpsy Sep 24 '19 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.