Redirect website from 1 domain to another

Say I have 2 domains, domain1.com and domain2.com. Both are on cloudflare. domain1.com is an old website with multiple URLs like domain1.com/blog or domain1.com/categories. Now I want all old domain and it sub URLs to open on the new domain, which means 1. domain1.com should open domain2.com 2. domain1.com/blog should open domain2.com/blog etc I have tried the page rule for URL forwarding https://developers.cloudflare.com/rules/page-rules/how-to/url-forwarding/, but that doesn't work. What should I do to make this work?
18 Replies
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
Can you clarify "doesn't work"? What was the rule you set and what part doesn't work
vijayasharma
vijayasharmaOP•7mo ago
Page Rule - forwarding URL https://www.domain1.com/* to https://www.domain2.com/$1 with 302 temp redirect no, i checked page rules first as this was what other support forwarded to me and I want to confirm before doing anything else
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
This is what I use and I can confirm it works maybe a dumb question but that rule wouldn't match https://domain1.com/* nor would it match http://domain1.com/* just making sure that wasn't what you were trying right?
vijayasharma
vijayasharmaOP•7mo ago
OK, i will try this first 🤞
vijayasharma
vijayasharmaOP•7mo ago
I used the above doc and saved these configurations, still not working, I can access both URLs/domains separately
No description
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
make sure your old configuration is disabled and the new one is enabled (Deployed and toggle switched on) also just to be sure that this redirect rule is set up on your domain1.com (not domain2.com), domain1.com is on Cloudflare, and domain1.com and www.domain1.com both have at least a placeholder A record with Cloudflare proxy enabled can you let me know what error message you get? like define 'not working'
vijayasharma
vijayasharmaOP•7mo ago
both domains are of hostinger, I just changed NS cloudflare and no A records for the domain1.com
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
that is why you're having issues
vijayasharma
vijayasharmaOP•7mo ago
I can access domain1.com and domain2.com separately Ohh, so what would work in that case?
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
domain1.com shouldn't work at all without A records you want domain1.com and www.domain1.com to redirect to domain2.com right?
vijayasharma
vijayasharmaOP•7mo ago
yes
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
go on the Cloudflare DNS page for domain1.com add 2 A records both pointing to 192.0.2.0 for domain1.com and www.domain1.com (this IP is a placeholder IP mentioned in the documentation here: https://developers.cloudflare.com/dns/troubleshooting/faq/#what-ip-should-i-use-for-parked-domain--redirect-only--originless-setup )
Cloudflare Docs
General FAQ · Cloudflare DNS docs
Yes. Cloudflare offers free DNS services to customers in all plans. Note that:
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
make sure the Cloudflare proxy is enabled for both of these (orange cloud) For "When incoming requests match..." change "operator to "is in" and in Value add www.domain1.com (it should include both domain1.com and www.domain1.com)
vijayasharma
vijayasharmaOP•7mo ago
I can't add A records because for @ and www, CNAME records already exists, which are of hostinger as I am using hostinger builder website
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
You have to pick 1, do you want domain1.com to point to your hostinger site or do you want Cloudflare to redirect it to domain2.com?
vijayasharma
vijayasharmaOP•7mo ago
Hmm, I understand, thanks for the help, I need to read more about this to understand what would be best approach I will update you, again thanks for the help
merp (Taiwan arc)
merp (Taiwan arc)•7mo ago
No problem
Want results from more Discord servers?
Add your server