Custom domain for website hosted on a subfolder

So I have a need for pointing a customer’s domain to a website hosted on Cloudflare domain

The customer’s domain is of the form abc.example.com while the domain on Cloudflare is of the form server.hosted.com/example. So I want abc.example.com to be pointing to a subfolder server.hosted.com/example

I’m aware of Cloudflare for SaaS but couldn’t find a solution for this use case. Could I know how it could be routed this way?

Hi there, thanks for your questions!

After adding the custom domain with Cloudflare for SaaS if needed, you can use Transform Rules to achieve this:

You need to create a new URL rewrite rule: https://dash.cloudflare.com/?to=/:account/zones/rules/transform-rules/rewrite-url/new

Add the hostname as a filter:
image

And then set a dynamic rewrite to concat("/example", http.request.uri.path)
image

Let us know if you have any questions :slightly_smiling_face:

Hi. So in this case will it append the path to the custom domain entered by the user?

And also how could this be done via API once the custom domain is created on Cloudflare?

Hi again!

It will append the path to the domain in the request sent to your origin server. So when the user visits https://abc.example.com/ Cloudflare will send a request to https://server.host.com/example/

This should help:

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