Embed another domain keeping the same source domain name in address bar

What is the name of the domain?

www.domainA.com

What is the issue you’re encountering

when I open domainA it shows domainB in address bar

What steps have you taken to resolve the issue?

Added redirect rule

What are the steps to reproduce the issue?

Cloudflare single redirect rule added for domainA hosted on cloudflare:
Dynamic concat(“https://www.domainB.com”, http.request.uri.path) 301

when I hit domainA it shows domainB in address bar
I want to show domainA when I hit domainA and in browser it shows contents of domainB

Screenshot of the error

You can’t do this with a Redirect rule.

Redirect is a literal redirect – taking you, in your case, from a defined URL on domain A to another URL on domain B… and that’s it.

What you’re asking for is a Rewrite.

But this requires rewriting the hostname – which the standard Rewrite Rules product does not support. See: Rewrite URL rules. In short, you need an Enterprise plan to do this with any Cloudflare Rules product.

But you may be able to proxy the entire site with a Worker (provided you have the permission to do this, there are no security restrictions in the way, and, of course, you have to write and deploy the Worker code yourself).

1 Like

thanks george

can you elaborate more about “Worker code”,
any link or tutorial to start with?

is the worker serverless?

cheers

Do you control the website? If so, you could just add domain A to it, the same way you added domain B.

I control both domainA and domainB

domainA nameserver/zonefile is on cloudflare
domainB nameserver/zonefile is on hostinger

dont want to point domainA to other hosting than cloudflare

If domainB is not active in your Cloudflare’s account, you can still do this kind of URL rewrite with Snippets. Here is an example, you just need to remove the status code logic from here: Route to a different origin based on origin response | Cloudflare Rules docs. This template is also available in the dashboard under Rules > Templates tab.

I am not able to find in Rules>templates

If you have access to Snippets, you should see a template called Serve Different Origin Based on Response further down the list:

Keep in mind that Snippets require a Pro plan or higher.

Even the Snippets option is not there

image

finally I have pointed to the hosting using A records

added A record in domainA zone file to point to hosting of domainB,
domainA is still on cloudflare

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.