My goal is to have the following occur, when the user visits the sites below to the left it takes them to the directories on the right:
www.example.com or example.com => /var/www/example/public_html/
*.example.com => /var/www/example/public_html/sites/%1/public_html/
I have tried the following:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example/public_html
</VirtualHost>
<VirtualHost *:80>
ServerAlias *.example.com
VirtualDocumentRoot /var/www/example/public_html/sites/%1/public_html
</VirtualHost>
The main domain works with or without www, but every time I try to visit any other subdomain it takes me to and gives me a 500 Internal Server Error. The URL changes to look like below when I type in a subdomain:
{subdomain}.example.com/sites/{subdomain}/public_html/
I am on Apache 2.4.7 and yes I have setup the WildCard on my DNS server. I would greatly appreciate any answers deeming that I have been slamming my head on a wall for 2 weeks trying to get this working.