Development Blog‎ > ‎

Hosting a Domain and a Subdomain from Different Hosting Service Providers

posted May 15, 2012, 9:03 AM by Mavrik Games
A few months ago, I wrote a post about my disappointment with Google Sites' inability to host dynamic web pages (namely, php). I had written a time clock application in php, in part to keep track of the amount of time I spend on various projects, but mostly because I wanted to learn a little php. After I finished it, I found out that there's no way for Google Sites to host that application. I thought about using a different hosting company, but I didn't want to move this site off of Google Sites because, one, I've spent so much time and effort creating all the content here, and two, I didn't want to have to pay to host it. A friend of mine told me about Freehostia, but there was still the matter of having to basically re-create the website over there. I could have purchased a new domain name, but that seemed silly just to host one simple application, so I decided to give up on it.

A few weeks ago though, I started wondering if I could just create a subdomain of mavrikgames.com and host it on Freehostia without transferring the entire website. As it turns out, you can, but after quite a bit of research, I really couldn't find any instructions that were all that helpful for a website novice such as myself. Sure, I found lots of posts telling how to do it, but they were all written as if you owned both hosting servers, not that you were trying to do it using two separate hosting companies (like Google Sites and Freehostia) and a DNS manager from yet another company (Godaddy). Also, for one who isn't totally familiar with DNS records (A records, CNAME records, etc), it can be very difficult to find a straight answer in plain English!

Eventually, through mostly experimentation and the few resources I could find (and after studying DNS records and management), I was able to piece together the system. I thought I'd write this post to help others who may be attempting to do the same thing. I'm not writing this as a tutorial or anything (there's not nearly enough content for that), but a few simple instructions should help.

Lets say you already have a domain called "domain.com" hosted with one company (ie: Google Sites) and you want to add a subdomain: "subdomain.domain.com" and host it with another company (ie: Freehostia). The first thing you should do is host the subdomain with the second hosting provider (Freehostia). You'll have to figure out how to do that with your hosting provider, but with Freehostia, you just have to click on the "Host Domain" button in the "Hosted Domains" tab. You have to specify the whole subdomain name (ie: "subdomain.domain.com") in the field where you enter the domain name to be hosted. If the Hosting service provider has an option to manage the DNS records, you can disable it because you manage the DNS records from the same place as the base domain. Once the subdomain is registered, you should see an IP address associated with it. Copy that IP address and head over to your DNS manager (ie: Godaddy).

In your DNS manager, you should see entries for A records and CNAME records. A CNAME record is just an alias for your domain, so typically (when you're hosting the subdomain with the same hosting company as the domain), any subdomains go there. When you're hosting the subdomain with a separate hosting company though, you actually need to add an A record. This is different in different DNS managers, but in Godaddy's, you just have to click on the "Quick Add" button. Under the "Host" column, just type in the subdomain name (ie: "subdomain"), and under the "Points To" column, you enter the IP address you copied earlier.

That should be it. It can take up to 48 hours, but that's not typically the case. With any luck, you should be able to test your new subdomain within an hour or two.
Comments