Handle 1000 of redirects

I am about to migrate everything to cloudflare workers. Most things are in place now, but we’re still missing how to handle all of our site’s redirects (I have a list of about 3,500 redirects of 301 and “DELETED”).

How could I handle this most effectively? Preferably would re-updating everything. Like a RewriteMap or something (although not entirely sure if this is supported on workers + how to go about it).

I would make a JSON of them and use the KV to lookup the key and if the key match, then create the appropriate redirect response.


That sounds interesting. Do you care to provide a little example? Perhaps I’ll write a blog post about it, and quote you.

Sorry, I don’t have the time to put that together.

In general, I try to help out a lot on forums, but when it’s complex or actual “work” - no.

1 Like

This kind of use case is perfect for KV. You don’t even need the JSON, you just

NAMESPACE.put(url, redirectUrl);

and then in your worker, NAMESPACE.get(url), and if it gives you something back, issue the redirect.