i fixed this by adding directive ServerAlias domain.tld *.domain.tld
You can find this for setup under Apache -> Your Virtual Domain settings -> Networking and Addresses -> Alternate virtual server names FIELD.
domain.tld *.domain.tld
Question
So I'm trying to set up a rackspace cloud server to host multiple sites (not servers) with a single IP. I installed Virtualmin/Webmin on an Ubuntu 12.04 LTS server. I created the directory /var/www/sites/testsite. Then I created a virtual host under Webmin->Servers->Apache Webserver with the following settings:
Address: Any
Port: 80
Document Root: /var/www/sites/testsite
Server Name: testsite.com
Then, to test it, I edited the hosts file on my local machine and added
[my.server.ip.address] testsite.com
Then went to testsite.com in my browser and problem is it's loading the default site (at /var/www) instead of the virtual one I just created (I verfied this by adding different index.html files in /var/www and /var/www/sites/testsite).
Here are the directives webmin created in /etc/apache2/sites-available/webmin.1372454178.conf
DocumentRoot /var/www/sites/testsite
<Directory "/var/www/sites/testsite">
allow from all
Options +Indexes
</Directory>
ServerName testsite.com
ServerAlias www.testsite.com
Solution
i fixed this by adding directive ServerAlias domain.tld *.domain.tld
You can find this for setup under Apache -> Your Virtual Domain settings -> Networking and Addresses -> Alternate virtual server names FIELD.
domain.tld *.domain.tld
OTHER TIPS
It our case we have forget to add server name initially and then webmin virtual host edit/delete, it does not updated Directive so Server Name was missing in it.. After adding Server name and Restarting apache it has started working perfectly..
Servers -> Apache Webserver: Select your virtual Server -> Edit Directives
Server Name: testsite.com
Others -> Command Shell
service apache2 restart
Open your web address in browser.
I have found that mixing 'Any' with a specific port doesn't play nicely for some reason.
Try updating the vhost settings to:
Address: Any
Port: Any
Document Root: /var/www/sites/testsite
Server Name: testsite.com
When doing so, ensure that you empty any boxes that were filled in as part of you selecting a specific port.
Also, just as a side note, get used to setting your sites to not allow directory indexing, unless of course specifically required.
So in the Actual Directives Set:
Options -Indexes
This will stop people digging around in your site. If of course you need to allow someone to view a directory, you can add permission to do so on a folder by folder basis using .htaccess