Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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.