Friday, May 22, 2015

domain name system - How to point 2 CNAME records to same external address?




I am fairly new to DNS managing. I have been attempting for a while now to point both my root domain @ and www to my GitHub account page user.github.io.




I have a CNAME pointing www to user.github.io., but for some reason I can't do a CNAME that points @ to user.github.io..



The error I'm getting is CNAME records cannot share a name with other records.



I don't have the slightest clue what that's supposed to mean, please help.



If it makes a difference I'm using DigitalOcean's DNS controls


Answer



You'll need a host that acts as a URL rewriter / redirector. You'll point your DNS for domain.tld to a host running a web server (preferrably something super lightweight. Stripped down Apache, or nginx, or heck lighthttpd). That web server will then accept for domain.tld and immediately 301 redirect to user.github.io.




As for www.domain.tld, you can use a CNAME record for that, but then you'll have two different behaviors:




  • People go to domain.tld and are then redirect to a different URL: user.github.io

  • People go to www.domain.tld and stay at www.domain.tld but see the content of user.github.io (Assuming github allows that, which I won't go into the details of)



So you probably don't want the above behavior. Instead you probably want to add www.domain.tld to the list of URLs that your lightweight web server will handle redirects for.




Don't read this:



You can find DNS hosts that do apex CNAMEs but they're bad. Don't do it. It probably won't work for what you want it to do anyway.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...