# [solved] apache and wild card subdomains, wildcard doc root?

## matttah

I am trying to setup something like this with apache:  

*.mysite.com -> /mnt/*/web

IE daum.mysite.com -> /mnt/daum/web

Any ideas on how to do this or the best way to do this?Last edited by matttah on Mon Mar 15, 2010 4:52 pm; edited 1 time in total

----------

## AllenJB

mod_vhost_alias: http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html

----------

## matttah

thanks!  looks like what I want however am having some trouble getting it to work, i have the following:

```

Listen 80

NameVirtualHost 10.210.235.176:80

<VirtualHost 10.210.235.176:80>

        ServerAdmin webmaster@xx.com

        DocumentRoot /mnt/xx/web

        ServerName stage.xx.com

        ServerAlias www.stage.xx.com

        ErrorLog /mnt/logs/error_log-stage.xx.com

        CustomLog /mnt/logs/access_log-stage.xx.com combined

        SuexecUserGroup "xx" "xx"

        <Directory /mnt/xx/web>

                Options ExecCGI Indexes FollowSymLinks ExecCGI

                AllowOverride All

                Order allow,deny

                Allow from all

        </Directory>

         <Directory /usr/share/php/data/symfony/web/sf>

           Allow from all

        </Directory>

        Alias /sf /usr/share/php/data/symfony/web/sf

</VirtualHost>

<VirtualHost 10.210.235.176:80>

        ServerAdmin webmaster@xx.com

        DocumentRoot /mnt/xx/web

        ServerName *.stage.xx.com

        ServerAlias www.*.stage.xx.com

        ErrorLog /mnt/logs/error_log-subdomains.stage.xx.com

        CustomLog /mnt/logs/access_log-subdomain.stage.xx.com combined

        SuexecUserGroup "xx" "xx"

        <Directory /mnt/subdomains>

                Options ExecCGI Indexes FollowSymLinks ExecCGI

                AllowOverride All

                Order allow,deny

                Allow from all

        </Directory>

        VirtualDocumentRoot /mnt/subdomains/%2/web

 <Directory /usr/share/php/data/symfony/web/sf>

   Allow from all

</Directory>

Alias /sf /usr/share/php/data/symfony/web/sf

</VirtualHost>

```

It seems that the first one (/mnt/xx/web) is getting all the requests, ie subdomain.stage.xx.com still is just going to there rather than /mnt/subdomains/subdomain/web.

Any ideas why?

Thanks,

Daum

----------

## matttah

This was because the ServerName can't have a * in it, removed that and it is working.

----------

