Rewrite/redirect or dns mapping


I have subdomains: “user1 dot vdofabric dot co dot nz”, “user2 dot vdofabric dot co dot nz”,…
and I have another two domains: “research dot com”," academic dot co dot nz"

I want bind research dot com to “user1 dot vdofabric dot co dot nz”,
and bind academic dot co dot nz to “user2 dot vdofabric dot co dot nz”

which means if user access “research dot com”, they will see the content of “user1 dot vdofabric dot co dot nz” but the url will not be changed.

Can I implement this in Cloudflare? Thanks

You can do this with either Cloudflare Workers or a combination of Resolve Override and Host Header Override (requires Enterprise plan).

However, it will only work if the user pages use relative URLs when linking to JS, CSS and images.

Hi Albert,

Thanks for your quick reply.

Could you help provide some links/tutorials about the cloud workers or another approach to implement this.


It’s can be as simple as deploying this Cloudflare Workers script on and

const MAPPINGS = {
	'': '',
	'': ''

export default {
	async fetch(request) {
		const requestUrl = new URL(request.url)
		if (MAPPINGS.hasOwnProperty(requestUrl.hostname)) {
			requestUrl.hostname = MAPPINGS[requestUrl.hostname]
		return fetch(requestUrl, request)

If you control the origin of I’d recommend simply adding the domains as aliases/virtual hosts instead of using Cloudflare Workers.


Does this Cloudflare workers working for dynamic website? or it only works for static website, because I see it’s using a fetech funtion to do a “Get” request.

Yes, I have full control of the original domain,, could you help show me how can I add aliases or virtual hosts? I already set up this wildcard dns proxy

This is something you will have to do at your origin server/website hosting. How you do it depends on your setup (which web server you use) and is beyond the scope of this forum.

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