Solved: Hosting Domain & Subdomain on different Servers

Sometimes, situations come up when we need to host different parts of a website on different servers. A common case is email servers of a domain that is hosted on a different host and the regular website is on a different host. This is done by routing email handling using MX records of a domain.

But, there are situations when we have on server 1 and on server 2. e.g In some case we may need to have the CRM part of the website developed by one company and website front-end developed by another company. The sensitive nature of data collected by the CRM may require it to be kept isolated from the regular website.

So, how do we host a subdomain and domain on two different servers?

Generally, to connect a domain to a particular server we set up nameserver at the domains registrar. But when we need to point domain to one server and subdomain to another server we cannot set two different sets of name servers. So, we set appropriate A records for domain and subdomain.

Here is an example how I set up subdomains and domains on two different servers on Godaddy registrar.

Step 1: Set up appropriate A Records in DNS Manager of your domain registrar

Setting up A records for domain and subdomain on Godaddy Registrar.

Note that I have set up 4 different IPs for different subdomains for one particular domain. I have highlited different setups in a different color for you quick understanding.

  • @ denotes the primary domain points to IP x.x.x.x
  • Subdomain (A record) points to y.y.y.y
  • Sudomain points to z.z.z.z and so on.

You can create a new A record in the DNS Zone Editor of your name server.
NOTE: This only works when the primary name server of your domain is set to your registrars default name servers.
Alternative: If you have already set a nameserver for the primary domain, then these A records will need to be created are the primary server’s WHM/cpanel or equivalent.

Step 2: Adding the required domain/subdomain to the appropriate server.

Now this step may be a little tricky. Follow the process mentioned below

  • Wait for the A records to propagate on NameServers and DNS records. It may take 30 minutes to 48 hours.
  • Add an addon domain to your hosting. Make sure you are adding the right subdomain to the right host. Cross check with IP address. Screenshot of domain addition is provided below taking cpanel as example.
  • In certain cases you may get error when adding the addon domain. In that case login to your WHM with root login >> Go to Server Configuration >> Tweak Settings >> Click on “Domains” Tab >> Allow Remote Domains set “On” >> Click “Save” at the bottom of the page.
Adding a subdomain on different server using addon domain feature of cpanel/whm