1

I have a doman, mydomain.com as well as mydomain.biz and would like the the latter to be a synonym for the former: whenever a user enters www.mydomain.biz they are taken to www.mydomain.com.

I have everything working for mydomain.com and thought, from my limited understanding that a CNAME record would accomplish what I'm trying to do, so I have

NS     mydomain.biz.    =  (nameservers that work fine)
SOA    mydomain.biz.    =  (values that work fine)
CNAME  *.mydomain.biz.  =  mydomain.com.

and when I host mydomain.biz I get

www.mydomain.biz is an alias for mydomain.com.

followed by other information that exactly matches what I get with host mydomain.com. Yet, any attempt to navigate to www.mydomain.biz fails.

I'm also perplexed by what I see when I look at propagation of my NS records. Checking for mydomain.biz gives the nameservers specified above, but checking for for www.mydomain.biz gives the values specified (elsewhere) for mydomain.com

Am I not going about this the right way? How should I configure my DNS records to direct all traffic from one domain to another.

Community
  • 1
  • 1
orome
  • 45,163
  • 57
  • 202
  • 418

1 Answers1

3

DNS cannot redirect a request. Lets take an example on what CNAME does to clarify:

CNAME: domainA ==> domainB

What that would do is send requests for domainA to the same IP as domainB. However the URL will remain domainA (so it's not a redirect, a redirect would actually change the URL).

If you are okay with having the site load under two different domains, then a CNAME record will do the job. However you need to make sure that your server is configured to handle requests from both domainA and domainB. The way you do that is very different depending on your server environment. For example if you are using apache, your virtualhosts determine what domains are handled (you could set it up so any domain is accepted). If you are on shared hosting however, you will likely be restricted to the domain you signed up with. Adding more depends on your web host so you'd have to take it up with them.

If on the other hand you want the visitor to be redirected to domainB, you'd have to point domainA to a server that would return an HTTP redirect. It could be the same server, you just need to configure it to return the HTTP redirect if the request is for domainA.

Faris
  • 877
  • 7
  • 9
  • So the answer I linked (and hundreds like it on the Web) about using CNAME for that purpose are wrong? – orome Feb 14 '15 at 01:49
  • 1
    I think the answer you linked is just misusing the word redirect. I found this http://stackoverflow.com/questions/593807/dns-gurus-how-to-forward-www-domain-com-to-domain-com-using-dns-only it explains it better. – Faris Feb 14 '15 at 01:51
  • So is my question, I think. The result I'm looking for is as described for CNAME, unless I'm missing something. And CNAME has worked for me in the past to accomplish this. – orome Feb 14 '15 at 01:57
  • A CNAME record will point domain A to domain B so that they both end up going to the same server, but the URL will still be the original domain A. If that's what you want then great. All you'd need to do is make sure your server expects requests with the host being domain A so it stops failing as you said. – Faris Feb 14 '15 at 02:05
  • So the server for B needs some configuration to receive A? That seems odd: In the cases where this has worked, the server hasn't been configured in any way — no for A or B. – orome Feb 14 '15 at 02:12
  • I'd need much more information about your server to be able to comment on why the server won't accept a connection from a different host, but in many cases yes you'd need to configure it. Let's take the simplest case as an example, if you are on shared hosting then you'd need to add the domain as an addon domain or something along those lines. – Faris Feb 14 '15 at 02:16
  • The ones that work currently (I've had others work in the past, but can't vouch for the details) are AWS EC2 instances (Elastic Beanstalk), load balanced. I can't see how they care anything about the URL directed at them, since I can change DNS records (only) and send whatever URLs I want their way. Perhaps the one that's not working (an old shared hosting) is specifically configured to *only* accept B? – orome Feb 14 '15 at 02:31
  • I'm a bit confused. Is "mydomain.com" on shared hosting? If so then you probably just need to add "mydomain.biz" to the server. Shared hosting is strict with domain names since it's shared. It won't matter at all with elastic beanstalk though so if it's on that then I'm sorry I have no idea what the problem is. – Faris Feb 14 '15 at 02:41
  • No, I think you may have hit on the issue (and bumped up against my ignorance): CNAMEs *work* when directed at AWS Elastic Beanstalk, but not when directed at my old shared hosting server. I'd never thought this through, but it makes sense now (I think, if you can confirm). On AWS the server is a VPS so I expect that it's all mine and comes unconstrained by what domain it accepts (I could change that of course); on my (in fact any) old shared hosting server there's something (in some Apache config file) that limits traffic to specific domains. Is that roughly right? – orome Feb 14 '15 at 14:38
  • Exactly right my friend. Usually on shared hosting you can add more domains from cpanel if you have it. Otherwise I'm not sure how you'd add it honestly. It all depends on your server provider. Some of them limit it to one domain unless you upgrade ect. – Faris Feb 14 '15 at 14:43
  • On a VPS system I think (at least with the ones I've tired) there's no restriction (it makes no sense, really, given the architecture). So the answer here is really that CNAMEs *do* work as advertised, but that one needs to be sure that the server itself isn't somehow restricting the domains it accepts, as would (have to be) the case for shared hosting. (And it would be great too if the answer mentioned briefly what back magic in server config is responsible for this.) – orome Feb 14 '15 at 14:47
  • And, regarding the last bit (and guessing here) if I look at [/etc/httpd/conf/httpd.conf](http://stackoverflow.com/a/16129490/656912) on my VPCs, I see (again guessing) no `VirtualHost` and `ServerName` is commented out, which (I gather) is *not* what one would see on a shared environment. Right? – orome Feb 14 '15 at 14:56
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/70917/discussion-between-faris-and-raxacoricofallapatorius). – Faris Feb 14 '15 at 15:25