Hello Matthew,
If I understand your question correctly, I am actually doing the same thing in one of my policies, I have frontend incoming URLs:
https://gateway.ca.com:8443/service/A/parameter?m=1...
https://gateway.ca.com:8443/service/B/parameter?m=3...
https://gateway.ca.com:8443/service/C/parameter?m=1...
Depending on the whether we have '/A' or '/B' in the uri these requests will be routed to https://backend.com/1/A/parameter?m=1 , https://backend.com/2/B/parameter?m=1 or https://backend.com/2/C/parameter?m=1 respectively.
I use one routing assertion in my policy dynamically changing the uri depending on whether we have '/A' , '/B' or '/C' in the frontend URL because that determines whether we are routing to https://backend.com/1/... , https://backend.com/2/... or https://backend.com/3/...
As an exampIe, when a request comes in with https://gateway.ca.com:8443/service/A/parameter?m=1, I use ${request.http.uri} to capture uri '/service/A/parameter' , do a simple compare to see if that uri contains '/A/' , '/B/' or '/C/' (you can use other logic) and then use the "evaluate regular expression" assertion on the captured uri to replace the '/service/' with a '/1/' ( I can also just drop the '/service/' by replacing it with a blank in the assertion, if I dont need to replace), and then append the modified uri and query to the backend route. The resulting modified URI and query will be "/1/A/parameter?m=1 ".
${backendUrl}$(modifiedUri}${request.url.query}
I hope this builds on Joe's help on this.
Wesley