I'm trying to follow on how to make subdomains that tails a specific directory, so for example I go to http://sub.mydomain.com and it should take me the root of /var/www/sub. http://randomdir.mydomain.com should take me to /var/www/randomdir.
I followed a lot of answers here on SF but none has helped at all. Basically what I have done is made a wildcard A record *.mydomain.com a couple days ago, now I've added a virtualhost in /etc/apache2/sites-enabled/mydomain.com.conf which contains this:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/
</VirtualHost>
<VirtualHost *:80>
ServerName cake.mydomain.com
ServerAlias *.mydomain.com
DocumentRoot /var/www/%1
</VirtualHost>
However, when restarting apache2, I get this returned:
Warning: DocumentRoot [/var/www/%1] does not exist
apache2: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName
... waiting Warning: DocumentRoot [/var/www/%1] does not exist
apache2: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName
How do I manage to create wildcard subdomains that point to a directory based on the prefix of the domain?