5

Is this even possible?

My current vhost.conf entries:

<VirtualHost www2.b-page.lv:80>
    ServerAdmin [email protected]
    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>
<VirtualHost www2.m-page.lv:80>
    ServerAdmin [email protected]
    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
</VirtualHost>

hosts file:

127.0.0.1       www2.b-page.lv
127.0.0.1       www2.m-page.lv

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

4 Answers 4

9

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.

0
2

dont forget to put :

NameVirtualHost 127.0.0.1:80

above vhosts definitions

1

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

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .