Why is my subdomain directing to the same folder as the main domain?

October 13, 2014 2k views

I've made one droplet, I'm trying to host a website on the main domain and roundcube (webmail software) on a subdomain (mail.domain.com). The problem is that the subdomain is directed at the same folder as the main domain so making a change to one automatically changes the other.

From what I can tell the main folder is located at: /var/www/html while the mail subdomain is at /var/mail but for some reason the subdomain is not pointing to that folder, its point to the main.

Below I've attached a screenshot of my DNS configuration:

DNS Configuration

1 Answer

DNS only maps a hostname (domain, subdomain, etc.) to an IP address, while the webserver (Apache in this case) decides what files to serve for each hostname.

You need to add a virtualhost for mail.domain.com that points to /var/mail, see How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS | DigitalOcean.

by Justin Ellingwood
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 14.04 VPS.
Have another answer? Share your knowledge.