I have some odd situation. I wan to make different DirectoryRoot for one domain.

example.com -> /dir1 www.example.com -> /dir1

*.example.com -> /dir2

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

link|improve this question
feedback

1 Answer

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com
  DocumentRoot /var/www/dir1
<VirtualHost>

<VirtualHost *:80>
  ServerName other.example.com
  ServerAlias *.example.com
  DocumentRoot /var/www/dir2
<VirtualHost>

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

See: http://stackoverflow.com/questions/758351/virtualhost-for-wildcard-subdomain-and-static-subdomain

link|improve this answer
<VirtualHost *:80> DocumentRoot = /var/www/wildcard ServerName other.example.com ServerAlias *.example.com <VirtualHost> This is not working. It is only forking for other.example.com. When I'm browsking to aaaa.example.com 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
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.