Apache – Multiple domain with the same ip and port in apache

apachednsdomain-namevirtualhost

I want to bind two different domain in my VPS with the same ip and port, here is my httpd.conf:

<VirtualHost 106.187.96.123:80>
    DocumentRoot /home/roy/sobuhu
    ServerName aaa.com
</VirtualHost>

<VirtualHost 106.187.96.123:80>
    DocumentRoot /disk1/allen/www
    ServerName bbb.com
</VirtualHost>

<VirtualHost 106.187.96.123:80>
    DocumentRoot /disk1/allen/www
    ServerName www.bbb.com
</VirtualHost>

Can I config the ServerName use syntax like *.bbb.com ?
so I can access www.bbb.com、bbs.bbb.com with the DocumentRoot /disk1/allen/www.

Now I visit bbs.bbb.com, it will turn to /home/roy/sobuhu.

Best Answer

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot /home/roy/sobuhu
    ServerName aaa.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /disk1/allen/www
    ServerName bbb.com
    ServerAlias *.bbb.com
</VirtualHost>