Cloudflare redirecting to from one domain to another? - .htaccess

Is it possible to redirect from domainA.com to domainB.com without domainA.com having any DNS records?
I have two domains that I need to direct to another domain- the two domains don't have any other function than to be redirected. On Cloudflare these domains do not have any DNS records. Can you do this without directing them to a server and do the operations via .htacces, but by simply configuring it on CF?
Thanks!

The domain needs to have DNS records running through our proxy for our PageRules to work.

Related

URL Rewrite using DNS only

i know you can't redirect the path portion of a URL with DNS only
But is this possible with DNS only?
app1.domain.com --> domain.com:4993
app2.domain.com --> domain.com:4994
(both are https only)
which DNS records do i need to add?
It's not possible with pure DNS. The DNS does not care about the port, but only about the domain. To achieve this check if your DNS provider offers Web Redirecting or Web Forwarding. It's not DNS only, but depending on the reason why you want it to be DNS only this might work for you.

DNS: forward root domain to www... when there are other DNS subdomains

I currently have a DNS setup where all content and applications are hosted on the same cloud server - example.com.
The presentation website is on example.com, www is forwarded to example.com with a CNAME and then various internal apps, eg app.example.com, are also forwarded with CNAME records to example.com. NGINX running on my server takes it from there, routing subdomains to the different apps.
I'd like to host the presentational website on an external service, and I'm confused about how to update my DNS config - specifically what to do with my A record.
I'm ok with creating a CNAME for www that will forward www.example.com to my external hosting service. But example.com is still pointing to my own server... and if I have understood correctly, if I forward example.com to www.example.com, then all my apps at eg app.example.com will break.
What are my options for handling this ?
My idea (from searching around) is that if I want example.com to point to an external service, then I should
1) create a new domain api-example.com whose A record points to a server where all my apps are hosted
2) make CNAME records for all my app subdomains on example.com which point to api-example.com
3) forward example.com to www.example.com, and forward www.example.com to the external service.
Will this configuration work ? Is there a simpler way to get the same result ?
Your plan is fine, except for maybe one thing: generally, you can't have a CNAME record for the root (apex) of your domain. This means that your external presentation website hosting will have to provide an IP address, and you will create an A record that will point example.com to that address. Then you can have a CNAME record simply aliasing www.example.com to example.com.
Also make sure that you leave enough time between the steps, to make sure that all DNS TTLs expired so you don't encounter DNS caching issues.
For explanation (and possible workarounds) for domain apex CNAMEing issue, look at https://stackoverflow.com/a/33027309/1145196

Cloudflare DNS - How to redirect all subdomains to root domain?

Can somebody tell me how I can redirect all subdomains to the root domain in Cloudflare DNS?
I have been looking for a day now without any luck.
I can't use .htaccess because all the subdomains doesn't resolve (They look just like a root domain that haven't propagated) and doesn't return anything, and I don't want to set up hundreds of DNS records for each possible subdomains.
I would like to set up a wildcard dns entry to redirect or at least make all subdomains reachable, so I can either do the rest via the .htaccess, or through DNS.
So how do I make the DNS entry for above requirements?
Thanks.
From the support: Does Cloudflare support wildcard DNS entries?
Cloudflare Free, Pro and Business plan:
We do not proxy wildcard records so these subdomains will be served
directly without Cloudflare performance, security, or apps. The
wildcard domain will have no cloud (orange or grey) on the Cloudflare
DNS Settings page for that reason. If you are adding a * CNAME or A
Record you need to make sure the record is grey clouded in order for
the record to be created.
To get Cloudflare protection on a wildcard subdomain (for example:
www), you explicitly have to define that record in your Cloudflare DNS
settings. First, log into your Cloudflare account and select the DNS
icon. In this example, you would add "www" as its own CNAME record on
your Cloudflare DNS Settings page and toggle the cloud to orange so
the Cloudflare's proxy is enabled.
Unless you are an Enterprise customer, you can't use a wildcard to redirect through Cloudflare.
Make sure the cloud logo is grey to add a wildcard record:

Which DNS records should i have for several subdomains and naked domain?

We have 3 sites/apps hosted on 3 different locations (IP addresses):
Angular app:
app.domain.com on IP 1.1.1.1
Web Service:
api.domain.com on IP 2.2.2.2
Web Sit/Blog:
domain.com AND www.domain.com on IP 3.3.3.3
So, we want domain.com to go to www.domain.com.
What is the right, best practice way to solve following case?
What DNS records should we have?
The Google recommends 301 redirect (see https://support.google.com/webmasters/answer/93633). Therefore it is neceessary to use URL record. See https://support.dnsimple.com/articles/differences-between-a-cname-alias-url/ for example.
If your NS-server does not support URL records then you need to add URL rewrite rule on your web-server. In this case:
In first, you should create two same A-records for domain.com and www.domain.com on NS-servers. Also you can use CNAME-record instead of second A-record.
In second, configure redirection on your hosting server (3.3.3.3). In this article considers the similar solution for IIS or Appache web server..

Can a secondary domain point to an existing nameserver and be redirected?

I have a client that has two domains.
ex:
domain1.net.br and domain2.net.
domain1.net.br is already registered in my aws route53 and has 4 nameservers assigned to it.
I told my client that he should use the same nameservers for domain2.net to make it redirect.
I tought this would work but It didn't.
Shouldn't any domain having the nameservers be able to redirect to another domain?
I told my client that he should use the same nameservers for domain2.net to make it redirect.
I tought this would work but It didn't.
You are correct, this will not work. Route 53 assigned unique name servers for each of your domains.
Shouldn't any domain having the nameservers be able to redirect to another domain?
HTTP redirects are not a function of a name server, but of a web server. The easiest way to redirect domain2.net to domain1.net.br is to create an Amazon S3 bucket and utilize the Web Page Redirects feature.

Resources