You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Graham Clarke <gr...@53tech.com> on 2008/09/04 18:39:46 UTC

[users@httpd] mod_vhost_alias 404 / ErrorDocument

Hi - I'd like to setup a meaningful error page for a virtual host that 
uses mod_vhost_alias.   If a visitor enters a url that doesn't exist on 
the server they're served a custom error page. 

Here's a simple example:

The vhost has:
VirtualDocumentRoot /var/www/html/customer/%1

Requests for http://samplesite.mydomain.com  will serve 
/var/www/html/customer/samplesite/index.html

However, if the user makes a mistake and enters 
"amplesite.mydomain.com"  apache throws an error.

My question is how to catch these cases and show a friendly error page 
rather than an ugly apache error?

Thanks,
Graham

-- 
Graham Clarke
53 Technology

+ www.53tech.com
+ grahamc@53tech.com
+ 603-643-9955


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_vhost_alias 404 / ErrorDocument

Posted by Dragon <dr...@crimson-dragon.com>.
Graham Clarke did speak thusly:
>mod_vhost_alias takes the requested URL and matches a directory on 
>the server.  The point of using mod_vhost_alias is so you don't have 
>to create vritual host record for each site on your server.
>
>my domain is setup as a wildcard domain, so *.mydomain.com will not 
>produce a DNS error.
---------------- End original message. ---------------------

OK, so you did not state that originally which is why I made the 
assumption I did.

So does the ErrorDocument directive not work for you?

http://httpd.apache.org/docs/2.2/mod/core.html#errordocument

You would put the appropriate directive in the default vhost section 
and it should work if I am not mistaken.

Dragon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Venimus, Saltavimus, Bibimus (et naribus canium capti sumus)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_vhost_alias 404 / ErrorDocument

Posted by Graham Clarke <gr...@53tech.com>.
mod_vhost_alias takes the requested URL and matches a directory on the 
server.  The point of using mod_vhost_alias is so you don't have to 
create vritual host record for each site on your server.

my domain is setup as a wildcard domain, so *.mydomain.com will not 
produce a DNS error.

Graham


Dragon wrote:
> Graham Clarke did speak thusly:
>> Hi - I'd like to setup a meaningful error page for a virtual host 
>> that uses mod_vhost_alias.   If a visitor enters a url that doesn't 
>> exist on the server they're served a custom error page.
>> Here's a simple example:
>>
>> The vhost has:
>> VirtualDocumentRoot /var/www/html/customer/%1
>>
>> Requests for http://samplesite.mydomain.com  will serve 
>> /var/www/html/customer/samplesite/index.html
>>
>> However, if the user makes a mistake and enters 
>> "amplesite.mydomain.com" apache throws an error.
>>
>> My question is how to catch these cases and show a friendly error 
>> page rather than an ugly apache error?
>>
>> Thanks,
>> Graham
> ---------------- End original message. ---------------------
>
> I think you might be confused here.
>
> The example you are giving would likely not even get to Apache in the 
> first place as it is likely to be a DNS error you are getting as the 
> "amplesite.mydomain.com" subdomain probably does not have a DNS entry.
>
> To verify this, see if you get a valid IP address when you query DNS 
> using nslookup or dig for the "amplesite.mydomain.com" host.
>
>
> Dragon
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  Venimus, Saltavimus, Bibimus (et naribus canium capti sumus)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server 
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>

-- 
Graham Clarke
53 Technology

+ www.53tech.com
+ grahamc@53tech.com
+ 603-643-9955


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_vhost_alias 404 / ErrorDocument

Posted by Dragon <dr...@crimson-dragon.com>.
Graham Clarke did speak thusly:
>Hi - I'd like to setup a meaningful error page for a virtual host 
>that uses mod_vhost_alias.   If a visitor enters a url that doesn't 
>exist on the server they're served a custom error page.
>Here's a simple example:
>
>The vhost has:
>VirtualDocumentRoot /var/www/html/customer/%1
>
>Requests for http://samplesite.mydomain.com  will serve 
>/var/www/html/customer/samplesite/index.html
>
>However, if the user makes a mistake and enters 
>"amplesite.mydomain.com" apache throws an error.
>
>My question is how to catch these cases and show a friendly error 
>page rather than an ugly apache error?
>
>Thanks,
>Graham
---------------- End original message. ---------------------

I think you might be confused here.

The example you are giving would likely not even get to Apache in the 
first place as it is likely to be a DNS error you are getting as the 
"amplesite.mydomain.com" subdomain probably does not have a DNS entry.

To verify this, see if you get a valid IP address when you query DNS 
using nslookup or dig for the "amplesite.mydomain.com" host.


Dragon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Venimus, Saltavimus, Bibimus (et naribus canium capti sumus)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org