If you don't want that ErrorDocument
to be defined for a specific domain then enclose the ErrorDocument
directive in a negated <If>
expression that checks that the requested Host
header is not example.com
(the domain you want to exclude).
For example (requires Apache 2.4):
<If "%{HTTP_HOST} != 'example.com'">
ErrorDocument 404 /404.html
</If>
The ErrorDocument
is defined for every requested host, except example.com
. (Obviously, you'll still get a 404 response for this other domain, when requesting a non-existent resource, but /404.html
will not be served.)
Aside:
the htaccess dosn't redirect you to the 404 page
Probably just terminology, but there is no "redirect" (as in an external 3xx redirect) here to begin with. The error document is served with an internal subrequest. You could change the ErrorDocument
directive so that it does trigger a "redirect", but that is rarely desirable.