Forward dynamic domain

I would like to forward:
Source URL: mydomain.com/ABCDE
To destination URL: mydomain.com/code=ABCDE

Please note: ABCDE is dynamic. Could you please help me set this up in Cloudflare Page Rules?
Thanks

You can try the new bulk redirect in cloudflare with preserve query string option

https://developers.cloudflare.com/rules/bulk-redirects

The URL shown does not include a query string. The desired configuration is subpath matching and preserve path suffix:
image

Bulk Redirects will not convert a path into a query string.

Also, the source and destination are the same in the OPs example, so at best you get a loop. Unless of course the example is not written correctly. There is no way with Bulk Redirects or Page Rules to do a regular expression.

I suspect the best way to achieve this is with two page rules. The first is a dummy to match mydomain.com/code= but do nothing (usually set something that is already set globally, like Always Use HTTPS). The second Page Rule then matches mydomain.com/* and forwards to mydomain.com/code=$1. The $1 parameter here matches the first instance of * in the Page Rule.

2 Likes

Thanks Michael! It really works. Thanks so much for your help!

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