orome
orome

Reputation: 48456

How should I configure my DNS records to direct all traffic from one domain to another?

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.

Upvotes: 1

Views: 3272

Answers (1)

Faris
Faris

Reputation: 917

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.

Upvotes: 3

Related Questions