I have Apache web server installed on local Windows 7 x64 machine. It has no global DNS name.

In default distribution it has virtual host configured in Apache/conf/extra/httpd-vhosts.conf file.

It has one directive

NameVirtualHost *:80

and multiple directives

<VirtualHost *:80>

with different

ServerName www.domain.tld

Different names are written in hosts file and all pointing to

Unfortunately, virtual hosts do not work. Only first <VirtualHost> tag seems to be active. Nothing said on httpd.exe starting and in error.log.

How to make virtual hosts working here?


I see no reason why DNS can be required. GET request contains symbolic name of the site, so, the server has all information to distinguish which virtual host was called.


I found that virtual hosts DO work (without DNS!). It is a problem with one specific host.

  • 1
    The reason that DNS is normally used is that that is what most web browsers USE to set the Host: header. HTTP/1.1 requires the right Host: header to talk to virtual hosted websites. That said, you are free to put anything you like into a local hosts file. – adaptr Feb 17 '12 at 11:28

Virtualhosts are configured in the following file : extra/httpd-vhosts.conf

Here is an example on how to configure a Virtual Host

<VirtualHost *:80>
ServerAdmin webmaster@website.com
DocumentRoot "/var/sites/website"
<Directory "/var/sites/website">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny   
    Allow from all

ServerName www.website.com
#ServerAlias www1.website.com
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common

Remember to :

Configure your Normal and Aliasses names on your DNS manager, and remember to include this file on the httpd.conf main directives.

Include conf/extra/httpd-vhosts.conf

  • 1
    Sorry, what is DNS manager? I have no DNS name on a computer as I said. – Suzan Cioc Feb 16 '12 at 20:23
  • After that, restart the server httpd -k restart – GersonO Feb 16 '12 at 20:24
  • Sorry I don't understand what to do. All you said was already done at my computer except DNS. – Suzan Cioc Feb 16 '12 at 20:28
  • Add the <virtualHost> tags as I mentioned on your httpd/conf/extra/httpd-vhosts.conf file, and make it fit to your servers name (The same name you configure on the dns otherwise it wont work) – GersonO Feb 16 '12 at 21:28
  • 1
    I have no DNS, as I said. I am controlling access with hosts file. See no reason why it can't work with hosts. – Suzan Cioc Feb 17 '12 at 10:51

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.