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 have some odd situation. I wan to make different DirectoryRoot for one domain. -> /dir1 -> /dir1

* -> /dir2

I'm trying settings with NameVirtualHost and ServerAlias. Could you help?

share|improve this question
NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot /var/www/dir1

<VirtualHost *:80>
  ServerAlias *
  DocumentRoot /var/www/dir2

The order is important - the 'www' vHost must precede the wildcard.


share|improve this answer
<VirtualHost *:80> DocumentRoot = /var/www/wildcard ServerName ServerAlias * <VirtualHost> This is not working. It is only forking for When I'm browsking to is is loading content form /var/www/example not from /var/www/wildcard – Petter Jul 7 '11 at 8:32
The equal signs should not have been present - I have edited the example above, hopefully it work for you. – cyberx86 Jul 7 '11 at 8: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.