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

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>
<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
</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!

share|improve this question

4 Answers 4

up vote 6 down vote accepted

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.

share|improve this answer
1  
Great, I'll dig in it, thank you. –  Kristaps Karlsons Feb 17 '10 at 17:47

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

share|improve this answer

dont forget to put :

NameVirtualHost 127.0.0.1:80

above vhosts definitions

share|improve this answer

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.

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.