<p>What is the correct syntax for rewriting URI with a path parameter? I'd like to rewrite all requests matching</p>
<p><code>/my-service/requests/{requestId}/history</code> (regardless of value of  <code>requestId</code> path parameter) to</p>
<p><code>/requests/{requestId}/history</code>.</p>
<p>Please note there is already another rule for <code>/my-service/requests/send</code>.</p>
<p>Thanks</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-service
  namespace: world
spec:
  hosts:
    - &quot;*&quot;
  gateways:
    - internal-gateway.istio-system
  http:
    - match:
        - uri:
            prefix: &quot;/my-service/requests/send&quot;
          ignoreUriCase: true
      rewrite:
        uri: &quot;/requests/send&quot;
      route:
        - destination:
            host: my-service.world.svc.cluster.local
            port:
              number: 8080
    - match:
        - uri:
            regex: &quot;/my-service/requests/.*/history&quot;.   //&lt;=for all path parameters  
          ignoreUriCase: true
      rewrite:
        uri: &quot;/my-service/requests/{requestId}/history&quot; //&lt;=??????
      route:
        - destination:
            host: my-service.world.svc.cluster.local
            port:
              number: 8080
</code></pre>

LubošCZ
<p>Matches to URIs are evaluated in order, thus it can be configured like this:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-service
  namespace: world
spec:
  hosts:
    - &quot;*&quot;
  gateways:
    - internal-gateway.istio-system
  http:
    - match:
        - uri:
            prefix: &quot;/my-service/requests/send&quot;
          ignoreUriCase: true
      rewrite:
        uri: &quot;/requests/send&quot;
      route:
        - destination:
            host: my-service.world.svc.cluster.local
            port:
              number: 8080
    - match:
        - uri:
            prefix: &quot;/my-service/requests&quot;
          ignoreUriCase: true
      rewrite:
        uri: &quot;/requests&quot;
      route:
        - destination:
            host: my-service.world.svc.cluster.local
            port:
              number: 8080
</code></pre>
