<p>This is what I want to achieve:
Route traffic to a service based on the URI prefix</p>
<p>Problem I'm facing:
Unable to segregate the prefix from the context path</p>
<p>Explanation:</p>
<p>I want to route traffic to a services based on the prefix.
Say, <em>/<strong>dev</strong>/service/context/path/</em>  and <em>/<strong>test</strong>/service/context/path/</em> .
But I'm not able to do so without changing the context path of the application itself.</p>
<p>Is there a way I can segregate the prefix part of URI from the context path of application?</p>
<p>This is what my VS looks like:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: servicea
  namespace: dev
spec:
  hosts:
  - &quot;*&quot;
  gateways:
  - dev-gateway
  http:
  - match:
    - uri:
        prefix: /dev
    route:
    - destination:
        port:
          number: 8080
        host: servicea
</code></pre>
<p>Thanks</p>

RMNull
<p>Not sure if I understand your question correctly. I guess you can just add a rewrite rule like this:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: servicea
  namespace: dev
spec:
  hosts:
  - &quot;*&quot;
  gateways:
  - dev-gateway
  http:
  - match:
    - uri:
        prefix: /dev
    rewrite:
       uri: /
    route:
    - destination:
        port:
          number: 8080
        host: servicea
</code></pre>
<p>By this your traffic for <code>/dev/service/context/path/</code> becomes <code>/service/context/path/</code>.</p>
