How to rewrite url in virtual service?

Istio Ingress Gateway will receive requests like the following:

I have two apps. One is api, and another one called products.

API: // Here I use API // api application expects this url without api

Products APP: // product used differentiate the app as product app. // application expects this.

How do I setup the VirtualService to route based on the prefix api, and product respectively but forward on the url without api, or product included as the application does not expect to see api, or product in the path.

This doc may help you.