Redirecting All traffic to Another Domain

Hello guys. I have two domains. One is touhidur.cf and the other one is touhidur.tk.

Now what I want to do is redirect all domain and subdomain queries of touhidur.cf to touhidur.tk. what I mean by that is every time you input touhidur.cf/* or subdomain.touhidur.cf/* you will be redirected to touhidur.tk/*. Now since Cloudflare has something called page rules I wanted to use it to achieve my desired output. Here are the DNS records and page rules that I set up. Note that I set up rule 1 & rule 2 because rule 3 didn’t work.

Now my theory behind this was simple. If Cloudflare DNS have the authorotity (or DNS records) over my domains and subdomains than it should be possible to redirect every domain and subdomain queries to another domain with Page Rules. Cause such queries are to be proxied through Cloudflare servers!

Now even though my subdomains.touhidur.cf queries are bring redirected to touhidur.tk somehow, for some reason touhidur.cf and www.touhidur.cf are not working. And I actually don’t have much idea how CNAME records work. I just inputted two cname records so that Cloudflare knows that those domains exist and try to automatically proxy them and I can use the Page Rules.

It would be great if someone told me how CNAME *.touhidur.cf > touhidur.tk is working and what should I do to achieve the result I wanted.

I just wonder, doesn’t the free cf and tk domains have forwarding at their interface? Do you need to do it via Cloudfalre?

Also, I see * (asterix) record and you are using a CNAME.

Moreover, maybe the below articles could help you with non-www to www, from one domain to another?:

1 Like

Ok I did the following…

A @ touhidur.cf 192.0.2.1 proxy
A www touhidur.cf 192.0.2.1 proxy
CNAME *.touhidur.cf > touhidur.tk

and in page rules,

*touhidur.cf/* > https://touhidur.tk/$2

And it works as intended.

But I cannot understand why subdomains are not being redirected without the CNAME record.

1 Like

@fritex do you know why subdomains are not working without the CNAME record?

Try modifying one of the page rules, you may have incorrectly configured it to redirect (likely to the wrong page)

@AppleSlayer it works. I just want to know why I need this CNAME record.

Because the DNS record has to exist for page rules to trigger on it

Yes but it won’t work if I put in touhidur.cf. I have to put in touhidur.tk or other domains. How it works actually.

Maybe using a page rule *.touhidur.cf/*? (see the * then dot to catch www, sub1, sub2 …)?

You can use A records rather than CNAME, but in that case you would need to know the host/origin IP address where the website/content is located.

You cannot have the same multiple records for your domain because you already have CNAME touhidur.cf record from the above screenshot. Moreover, you cannot add domainC, domainD, domainE to your DNS records of domainA.

Add a new record CNAME subdomain and point it to touhidur.tk, then use the suggested Page Rule to catch the needed.

  • or maybe you want to achieve a redirection from subdomain.domainA.tldA/* to subdomain.domainB.tldB/*?

The page rule in the following post is the only page rule I currently have.

Tried a dummy A record. But cf won’t proxy wildcards for free accounts. So, it didn’t work. Maybe I should do who.is/dns/touhidur.cf and use the ips for the proxy?

I know. What I mean’t by that is I tried to add a record CNAME *.touhidur.cf > touhidur.cf but it didn’t work. Then again I tried CNAME *.touhidur.cf > touhidur.tk and it worked for some reason. I wan’t to know what the reason is.