Transform Rewrite rules for Cloudflare custom domain

I was going through Cloudflare Rewrite rules for appending custom path for custom domains for a use case where I have customers setting up custom domain like

abc.example.com (Custom domain to set on Cloudflare)

which needs to internally point to

xyz.lorem.com/first (existing domain hosted on a server which Cloudflare needs to point to)

Rewrite rules

But there seems to be the option to only have 10 active transform rules. How can I do more than 10 rewrite rules or is there a better way to do this?

You cannot use Transform Rules to rewrite the host. You can only rewrite the path, the query string, or both.

To modify the hostname, you’d need Origin Rules (beta) and an Enterprise Plan.

You can always use Redirect Rules (beta). The number o available rules vary by plan type, and you’d need to upgrade plans in case you need more Redirect Rules.

But here in this earlier thread, there’s the option mentioned in the final reply where they mention that the host can be rewritten too? Custom domain for website hosted on a subfolder - #3 by goutham.chandran

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/

If not for the rewrite rule, is there another option or is it only possible with custom middleware which runs and serves the appropriate page?

You’re right, I forgot that possibility. In the case discussed in that thread, the hostname is not changed by the Transform Rule, but by another service called Cloudflare for SaaS. On top of that, a Transform Rule is used to pass (and modify, if needed) the input path to the final domain.

Notice that what was suggested was to prepend a path to the requested path by use of concat("/example", http.request.uri.path), but by using Cloudflare for SaaS the hostname would’ve also changed in the process.

I’m not familiar with Cloudflare for SaaS, but it may fit your use case, please check the documentation:

Oh but in that case are only 10 rules allowed? Or is there a better way to do it using Cloudflare for SaaS?

The Transform Rule limitation applies. However, the hostname is not handled by the transform rule, but by Custom Hostnames created on your account for each customer domain, under Cloudflare for SaaS.

As I said, I’m not familiar with how Cloudflare for SaaS works, but hopefully other members of this Community may be able to help you further. For that, you may prefer to open a separate topic explaining in more detail what setup you want to create, and what needs you have, besides having customer domains rewritten.

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