The Apache documentation explains, how can we set up custom error pages for different HTTP errors, identified by their status code (401, 403, 404, 500, 503 and so on).
However, what this document says, is essentially this: in the case of an error, Apache generates an internal sub-request for a document.
For example, an
ErrorDocument 404 /errors/dunno.html
ErrorDocument 500 /errors/sux.html
lines will result that the documents /errors/dunno.html
and /errors/sux.html
will be served in the case of a 404 (file not found) or 500 (internal server) error.
However, it also means that a http request for https://my.server/errors/sux.html
will serve that sux.html
, as an ordinary file.
This is not what I want.
I want the error pages should live out of the DocumentRoot
, and they should be totally unreachable with ordinary http queries. The only case, when they should be served, if Apache serves a (non-200) http answer which is affected by an ErrorDocument
directive in its configuration.
Can I somehow do this?
mod_rewrite
'sIS_SUBREQ
condition ornosubreq
flag to recognize the subrequest and treat it different from ordinary requests. (Note there might be subrequests in other circumstances, too)