Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

What is the difference between "NameVirtualHost *" and "NameVirtualHost 0.0.0.0"? Both seem to be implementing name-based virtualhosts, both seem to work. How does "0.0.0.0" become a wildcard?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I believe they are the same from brief look at the code:

AP_DECLARE(void) ap_init_vhost_config(apr_pool_t *p)
{
     ...
}
 /* Parses a host of the form <address>[:port]
...

Then:

if (strcmp(host, "*") == 0) {
        rv = apr_sockaddr_info_get(&my_addr, "0.0.0.0", APR_INET, port, 0, p);
...
else {
        rv = apr_sockaddr_info_get(&my_addr, host, APR_UNSPEC, port, 0, p);

So it looks like * just gets parsed to 0.0.0.0 in this instance, and if it actually is 0.0.0.0 it will get passed as such (Although maybe APR_INET vs. APR_UNSPEC matters, but I think that might just be IPv compatibility thing, so maybe there is a difference in that IPv4 when 0.0.0.0 and IPv6 is possible when *, not sure). But I could be interpreting this totally wrong, you can see for yourself in server/vhost.c.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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