Subdomain redirecting to another server

2019-03-11 04:13发布

问题:

I have a website hosted on a shared hosting plan. My domain name is registered at GoDaddy, and the nameservers are those of my shared hosting (so far, all normal).

But I'm trying to figure out how to add a subdomain and point it somewhere else. I would like to point sub.mydomain.com to some other ip (on Amazon AWS). I would like to have it behave like a normal domain, and not a simple header('Location: ...') or window.location.href.

Is this even possible? If so, how do I do?

Thanks

回答1:

Yes it is possible. In the GoDaddy Control Panel, edit your DNS Zone File and add a "A record" for the subdomain. You should already have a A record for your main domain mapped to "@". Add a new entry using the subdomain prefix as host, e.g.:

Host    Points To

@       <main domain IP address>
sub     <subdomain IP address>

The second line should allow you to access the subdomain using sub.mydomain.com, while the main domain will still be accessible using mydomain.com.