Pointing main domain to another server while keeping subdomains in same place

I have a domain I want to point to my github pages site. However, I want to keep the subdomain old.mysite.com pointing at the current server (as this is an archive of my old php blog, which github pages can't host).

How would I go about doing this (Ideally using the tools available in cPanel)?


Solution 1:

You can create the following DNS records:

www.mysite.com  CNAME  youruser.github.io
old.mysite.com  A      ip.address.of.your.server

Given that you can't have a CNAME on the bare domain (mysite.com) you should point it to your server and make it a redirect to www.mysite.com on the http level. GitHub can also take care of the redirect for you, but I would avoid doing that as you will need to keep the A record up-to-date yourself (ALIAS records are rare). See the GitHub docs