0

We have a domain, example.com for instance. In our DNS settings for this domain, we've created a forward for give.example.com subdomain to redirect to another website which works great. (It's basically just an A record with give as the host and the IP of the site we're redirecting to as the value).

However, if you try www.give.example.com, it does not work. I've read that you can add a CNAME record to remedy this, but I can't figure out exactly what I need to add.

1
  • 1
    It isn't possible to implement redirects without web hosting. Only a web server can issue a redirect. DNS alone cannot be used to do redirects. Even a CNAME is not a redirect. It just says that the host name should be resolved to the same IP address as some other name. You need some sort of web server on that IP address to do the redirects. Commented Apr 6, 2021 at 22:58

1 Answer 1

5

www.give.example.com is exactly like give.example.com in the DNS, but they are separate names, so once you put a record for give.example.com that says nothing for www.give.example.com (except in cases of delegations, which is not the case here).

So you need records for both, such as in your zonefile (or equivalent in any provider UI or API):

give A 192.0.2.42
www.give A 192.0.2.42

(you can use separate IP addresses as well, of course).

You can use a CNAME if you prefer (and want/need the same IP address anyway for both), in any direction:

give A 192.0.2.42
www.give CNAME give

or

give CNAME www.give
www.give A 192.0.2.42

All names are written in relative fashion, so could work for any zone. If you need absolute names, remember to tackle .example.com. (including final dot) to every names above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.