I'm trying to configure Apache2 to host different sections of my website for varying host names of the URL using name based virtual hosts.
My server is running Debian 7 with Apache version 2.2.22.
- "example.com" and "a.example.com" will have the root directory /var/www/a/ (and is the default site)
- "b.example.com" will have the root directory /var/www/b/
Below shows the edits I've made to the configuration files of Apache:
NameVirtualHost *:80 Listen 80 ....
<VirtualHost *:80> ServerName a.example.com DocumentRoot /var/www/a/ </VirtualHost>
<VirtualHost *:80> ServerName b.example.com DocumentRoot /var/www/b/ </VirtualHost>
I've run "a2ensite b" and "service apache2 reload".
The index page of the the b site can be loaded becasue when I switch the document roots around, as in set the default side to /var/www/b/, I get the index page of site b when I go to (what would be) a.example.com.
The site is also definitely enabled as I can see the shortcut to the config file of b in the "sites-enabled/" folder