This uses a Cloudflare D1 database (broker_db). links have to be under the slug `/link/slug/`.

The link will get redirected to the destinationURl specified in the database. For instance, visiting https://kenyaforexfirm.com/link/fxpesa/ redirects to https://kenyaforexfirm.com/goto/fxpesa/ which then redirects to the final destination.

This is actually a genius way to hide from affiliate networks where the traffic is originating from. We could also try to manipulate our content so that naked afffiliate links are routed to the redirects.

Idea for Payload CMS Link Content Using afterRead Hooks

We would need some fields (especially the redirect domain name if we are not going to use the primary API domain name).

How to make a link such as https://ajira.com/link/fxpesa/ reroute to the PayloadCMS endpoint

Build a Cloudflare worker for redirecting and randomizing urls. From our domain eg Say we have a link such as https://ajira.pro/link/fxpesa/. When this is visited it interacts with a D1 database where it should choose a random url from a group of urls related to it (should the slug after /link/ be the identifier? eg /link/fxpesa/ /link/exness/ or /link/hfm/ ???) and redirect to that chosen url. Then we possibly have an array of links related to the slug???

With Payload CMS Data

Create a worker that checks whether the visited link contains a slug that is in the Link Redirect collections.

If the slug, exists, choose a random affiliate link from it and redirect to it.