Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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>
    DocumentRoot /www/
    ErrorLog /www/Apache22/logs/error.log

<Directory "/www/">
    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

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, 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:

The <Directory> and <Files> directives, along with their regex counterparts, apply directives to parts of the filesystem. Directives enclosed in a <Directory> section apply to the named filesystem directory and all subdirectories of that directory.

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


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.