httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: [users@httpd] VirtualHost with no ServerName in 2.2.11
Date Thu, 14 May 2009 22:37:58 GMT
Tony Ser wrote:
> Thanks for the reply.
> What we are trying to do is to create a new vhost without disrupting the default settings.
> So that http://localhost/whatever/... Follow the default setup while
> http://localhost/testsite/... Will refer to /var/www/company/yyy/public
> I did look into the suggested link but most examples on multiple vhosts rely on either
different port, different ip address, or different name but in our case they are all the same.
It is just a path that we want to take over.
> I realize the default DocumentRoot /var/www takes over all requests, and I am just wonder
if there is a way override it just for a particular path "testsite". Or do we always need
to edit the default config?
> Editing the default config is fine for a particular server but we are working on a web
application, to be deployed on different machines. Would be nice if we could just add our
own vhost configuration without messing with the default.
Well, that's a bit different from what you requested in the first iteration.

I believe that what you are trying to achieve will be difficult to do 
"in all generality", because these different hosts are likely to have 
different configurations to start with.
For example, not all of them may be configured to use VirtualHosts in 
the first place.

But assuming that they all are, I think you cleanest bet at this stage 
would be to add another VirtualHost, but with a different hostname, 
rather than trying to play with a sub-directory or Alias.

In any case, you cannot use a <VirtualHost> section just to redefine a 
part of an existing webserver.  That is not what VirtualHosts are for, 
nor how they work.

Thus, suppose you have a site which currently responds to 
"", and has its document base in /var/www (or 
And you want to add a "test site" with a different document base.  What 
you would then have to do is :

- in the DNS system of "", create a new alias (in DNS linguo, 
that's a CN record) for this same host. For example 
"", as a new alias for "".

- then in the Apache config of that host, create a new VirtualHost 
section *after* the ones that already exist :

<VirtualHost *:80>
   DocumentRoot /somewhere/else
   .. whatever else you want there ..

an then just put your test application under /somewhere/else (or under 
/somewhere/else/testsite if you prefer).

The above refers to the part "Name-based virtual hosts" in the 
previously-mentioned documentation.  IP-address based virtual hosting is 
something else altogether, not to be mixed or confused with this.

There may be other solutions based on mod_rewrite or Alias, but I 
believe that this will in the end be more complicated, and lead you into 
a bunch of issues of all kinds with relative URLs, authentication and 
authorization, existing aliases etc..

Using a separate virtual host as indicated above is like adding another 
webserver machine, completely separate from the original one, where the 
possibilities of mixup are limited.

I recommend you re-load this document :
and re-read carefully in particular the section
"Using Name-based Virtual Hosts"
(Just ignore whatever it says about IP addresses, and use "*" for that.)

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