ErrorDocument 404 not found in non-existent subdomain

Posted by Question Overflow on Server Fault See other posts from Server Fault or by Question Overflow
Published on 2012-09-13T14:14:29Z Indexed on 2012/09/14 15:40 UTC
Read the original article Hit count: 234

Filed under:
|
|

I am trying to get the apache server to issue a custom 404 error for invalid subdomains. The following is the relevant part of the httpd configuration:

Alias /err/ "/var/www/error/"
ErrorDocument 404 /err/HTTP_NOT_FOUND.html.var

<VirtualHost *:80> # the default virtual host
  ServerName site_not_found
  Redirect 404 /
</VirtualHost>

<VirtualHost *:80>
  ServerName example.com
  ServerAlias ??.example.com
</VirtualHost>

What I get instead is this:

Not Found

The requested URL / was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I don't understand why a URL to non-existent-subdomain.example.com produces a 404 error without custom error as shown above while a URL to eg.example.com/non-existent-file produces the full custom 404 error.

Can someone advise on this. Thanks.

© Server Fault or respective owner

Related posts about apache2

Related posts about httpd.conf