S
S
split_horizon2019-09-11 15:17:40
Domain Name System
split_horizon, 2019-09-11 15:17:40

How to register a CNAME record to transfer to another domain?

Hello, I have a site that has been running on hosting for a long time, its domain name is example1.ru.
We recently purchased a second domain - example2.ru.
The question is - how is it necessary to register a CNAME record in the DNS hosting of the example2.ru domain, so that when you enter example2.ru in the address bar of the browser, the page of the site example1.ru is opened?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Kuznetsov, 2019-09-12
@WSGR

1. It is fundamentally important to understand that DNS records (neither CNAME records, nor any others) do not implement a redirect (redirect). This is done on the web server side.
To put it simply, when a DNS server with the record "example2.ru CNAME example1.ru" is asked "what is the IP address of the example2.ru domain, it only answers, the same as that of the example1.ru domain", but no redirects at its level it does not implement.
2. How to make a redirect - firstly, it depends on your hosting (often there is a separate option for this in the control panel), and secondly, there are several options. A lot has been written about this and is easy to google, so I won’t dwell on it in detail, but as the simplest example, make a Redirect 301 via .htaccess. Also, sometimes registrars/DNS hosts provide a redirect service. But in your case it is reasonable to do it on the side of the same hosting.
3. Just in case. If you want example2.ru to be displayed in the address bar of the browser, then you don’t need to do a redirect, just link the domain to the site as an alias.
4. Now for the DNS records. Of course, in order to bind the example2.ru domain to a web server, you need to use DNS records that will point to this server.
5. A CNAME record can only be created for a subdomain (for example, for subdomain.example2.ru). For example2.ru, this cannot be done according to standards (more precisely, it is not recommended according to RFC). Technically, this can be done (but not always), and it will even work, but it is better not to do this for many reasons.
6. Some DNS hosting providers provide an option for such cases, which is called differently, but, as an example, "ANAME-record". Technically, this is not a separate record type, a regular A-record + monitoring records of the domain that this option refers to. Simply put, they keep track of which IP address the target domain is pointing to, and if it changes, they substitute it into the value of the A-record.
7. Finally, CNAMEs are used when the IP address of the target domain can "arbitrarily change", and in your case probably not needed at all, and still easier. Because both domains are yours, obviously you know the IP address of your web server, just create an A record for the example2.ru domain pointing to this IP address.

A
Andrey Barbolin, 2019-09-11
@dronmaxman

Specify the same IP for both domains. If necessary, resolve the web server settings on the server.

L
lubezniy, 2019-09-11
@lubezniy

In DNS - in any way. It is better to make a virtual host on the main server with an http redirect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question