Is this even possible?

My current vhost.conf entries:

<VirtualHost www2.b-page.lv:80>
    ServerAdmin example@example.com
    DocumentRoot "C:/xampp/htdocs/b-page"
    ServerName b-page
    ServerAlias www2.b-page.lv
    ErrorLog "logs/b-page.lv-error.log"
    CustomLog "logs/b-page.lv-access.log" combined
<VirtualHost www2.m-page.lv:80>
    ServerAdmin example@example.com
    DocumentRoot "C:/xampp/htdocs/m-page"
    ServerName m-page
    ServerAlias www2.m-page.lv
    ErrorLog "logs/m-page.lv-error.log"
    CustomLog "logs/m-page.lv-access.log" combined

hosts file:       www2.b-page.lv       www2.m-page.lv

These pages will run on the same server, with same CMS. Any help or guides would be very appreciated. Thanks!


Yes it is possible and quite common, you want name based virtual hosts. There are basically two types virtual hosts, name based and ip based. It gets more complicated with name based if you intended to run SSL, but it is still possible.

It works by looking at the HTTP header in the request to see the domain name being requested.


If the configs are as straight forward as your examples, then you may want to look at mod_vhost_alias


dont forget to put :


above vhosts definitions


Note that NameVirtualHost support depends on HTTP version 1.1 or later. You'd be hard pressed to find a copy of any browser or HTTP tool (wget, curl, etc) that didn't support at least that version or newer.

The concept is that the name of the server/host is included in the URL request headers with that version or later. HTTP 1.0 allowed one to request the URL without specifying the server's name (on the initially reasonable assumption that any URL was a "local" resource since a TCP connection had already been established to "the" target server). Back in the 1990s (yes, in the last millennium) the concept of a service on a server ... and the concept of a hostname were viewed somewhat differently than today. The "web" was really the first successful attempt to create a global namespace for information across the Internet. Old protocols like gopher, wais, and archie were efforts at linking, indexing, and cataloguing the resources. However, that's not quite the same as creating a namespace. The notion of "vanity" domains, and attempting to select host and domain names to convey part of the information ... or at least the branding ... of the resources "there" were nascent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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