httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: [users@httpd] Subdomain Config Questions
Date Tue, 17 Jun 2008 13:39:11 GMT

Aaron Todd wrote:
> Everyone,
> Thank you for all your help.  There was some good stuff in there.  But
> ultimately I followed this web site:
> This is giving me what I want, minus the environmental variable.  Now that I
> think about it I should be able to pull out the entered subdomain using PHP
> and will use that to customize the content.
Fine, if that is what you want, who else could complain ?

But I would like to make a comment, so that not everyone would jump on 
this as being the universal panacea.

It will be fine as long as you remember that using that configuration

1a) any access to any hostname ending in is going to hit 
your (single) virtual server, including some you do not necessarily expect.
For instance, you will gets hits to (which you expect), but also to
which you might not expect.

1b) if this virtual server is the only one (or just the first one) which 
you define in your httpd.conf, then it will also get hits for instance for  (assuming this is your IP address)
(meaning someone hitting your site by providing it's IP address, and 
bypassing the DNS entirely).
It will do that, because this virtual server will also be your default 
virtual server, which Apache will default to if it cannot match any
ServerName or ServerAlias directive.
( would not match a "ServerAlias *")

1a and 1b may look like the same case superficially, but they are not 
really, and happen for different reasons.

2) the respective domains which you do expect (and the others) will be 
handled by one single virtual server, thus with exactly the same 
configuration.  There is thus no way to have an ever-so-slight 
difference in settings for one subdomain, unless you really do that all 
dynamically.  For instance, if each domain had a different "company 
logo", you would need to choose among them dynamically at runtime.
The same with css stylesheets, authentication rules, etc..
Unless you have a neat tool that does all of that for you automatically, 
this might be a real hassle.

I guess that in the end it depends on how many of those subdomains you 
expect to handle, and how much they would differ from one another.
If you expect a large number, and they are all identical, then a 
solution like this would probably be best.

If on the other hand your sites are just a few, and they share some 
things but not others, then you might want to look at the other 
solution, and just share a DocumentRoot between them, or between some.

There are even ways to "build" a virtual server configuration 
on-the-fly, thus combining the characteristics of both designs above.
And then, there are mod_rewrite and SetEnvIf...


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message