Simple conditional redirects based on query string values

Hi! I’m new to the workers scripts and learning to transfer some of our use cases to the cloud. In NGINX, we have a link redirector that redirects based on the query string, i.e:

https://www.example.com/redirector

For example, if this link will receive:

https://www.example.com/redirector/?url=https://sample1.com/path1&param2=val2&param3=val3
redirect it to: https://tracker1.com?url=https://sample1.com/path1&param2=val2&param3=val3

https://www.example.com/redirector?param1=val1&url=https://sample2.com/path2&param3=val3
redirect it to: https://tracker2.com?param1=val1&url=https://sample2.com/path2&param3=val3

else return a 404

We have this system set up in NGINX with regex matching on the values of the url parameter. I’m wondering how to implement this using a worker script as this should lower the latency. A simple script would be appreciated. Thanks for any nudge on the right direction!