Take the 2-minute tour ×

I'm running Apache 2.28 on Windows 7, and this is my directory structure:


www (which contains the Apache server, it's the free Web-Developer Server-Suite, that's its default configuration of C:/www/)




and I added to httpd-vhosts.conf:

    <Directory C:/www/vhosts.1>   
  Order Deny,Allow   
Allow from all 
   <Directory C:/www/vhosts.2>   
Order Deny,Allow   
Allow from all 

but just to test that I could put them anywhere, I then added a virtualhost, added the domain to the HOSTS file, and put it in C:/www (the main webroot).

This was for the latest domain I added:

<VirtualHost *:80>
    ServerName  testing-server-win7.co.uk
              ServerAlias  www.testing-server-win7.co.uk
    DocumentRoot /www/testing-server-win7.co.uk
    ErrorLog /www/Apache22/logs/error.log

<Directory "/www/testing-server-win7.co.uk">
    Options All
    AllowOverride All
    order allow,deny
    allow from all

and it worked, surprisingly.

Why is this, and can you really place them anywhere on Apache?

This is a development server, btw, not open to the Internet - although the computer does have Internet access.

Anyone tried this here, and did it work for them?


share|improve this question

2 Answers 2

I'm going to guess that you need to change the direction of the slashes you are using for c: - it should be C:\ instead of what you have C:/

share|improve this answer
It's in C:\, I just mistyped the slashes. –  Laqua Mar 17 '11 at 20:40

The HTTP protocol has a header field called Host. This is what makes virtual hosts possible.

Your browser tries to reach testing-server-win7.co.uk, which your hosts file translates to the appropriate ip.
Aside from sending the HTTP GET request to that ip, it also sends the hostname (by using the Host header field), which seems redundant at first, "Surely the server knows his own name".

Apache can read this and figure out which site you are trying to reach. Then it serves that site to you.

From the documentation:


In other words, if you reference a directory of your filesystem with a <Directory> tag in the config file, Apache can serve stuff from it. All you have to do is make it a document root for a virtual host (as you have).

share|improve this answer
I get that, but was unsure if the direction of the slash mattered. So basically, the directory location doesn't matter then? –  Laqua Mar 17 '11 at 20:44
Ah, missed that part. As long as it is in the web root, or another directory that is referenced by an apache config file, sure. –  Kenny Rasschaert Mar 17 '11 at 20:47

Your Answer


