VirtualService and Path based routing to different kubernetes services

Hello Guys,

I want to do path based routing using virtual service. Is it possible?

example.com/app1 → request goes to app1 service(app1.default.svc.cluster.local)
example.com/app2 → request goes to app2 service(app2.default.svc.cluster.local)

While I have not tested this, I think you can do this in a VirtualService. Here is an example:

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: example-com
spec:
  gateways:
  - your-gateway-here
  hosts:
  - example.com
  http:
  - match:
    - uri:
        prefix: /app1
    route:
    - destination:
        host: app1.default.svc.cluster.local
  - match:
    - uri:
        prefix: /app2
    route:
    - destination:
        host: app2.default.svc.cluster.local