APACHE
How to get "anysubdomain.mydomain.com" automatically routed to a directory?
- enable mod_vhost_alias (create symlink in mods-enabled)
- create the following vhost configuration file
/etc/apache/sites-available/subdomains
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias *.mydomain.com
VirtualDocumentRoot /path/to/webspace/%1/public
SetEnv APPLICATION_ENV dev
</VirtualHost>
3.) to enable, create symlinks for subdomains in /sites-enabled
4.) restart apache
Pro tipp no. 1:
I set VirtualDocumentRoot
to /var/www/
where I only have a load of soft links to my actual projects.
Pro tipp no. 2:
%1
will stands for the name of the subdomain only meaning, if someone opens sub.mydomain.com, apache will look for /path/to/webspace/sub/public
. if you use %0
the whole domain name is used /path/to/webspace/sub.mydomain.com/public