<p>I have an Istio 1.4.6 VirtualService with a match and a url rewrite defined as follows:</p>

<pre><code>    match:
    - authority:
        prefix: example.com
      uri:
        prefix: /foo/bar
    rewrite:
      uri: /
    route:
    - destination:
        host: some-service
        port:
          number: 80

</code></pre>

<p>I would like a rewrite like follows:</p>

<p>Traffic directed to <code>/foo/bar</code> or any subpath of that should be rewritten to <code>/</code> plus any subpath on <code>some-service</code>.</p>

<pre><code>i.e.
example.com/foo/bar -&gt; some-service
example.com/foo/bar/subpath -&gt; some-service/subpath
example.com/foo/bar/subpath/anothersubpath -&gt; some-service/subpath/anothersubpath
</code></pre>

<p>However, when I sysdig the traffic coming into <code>some-service</code>, I see that Istio has rewritten the path to:</p>

<pre><code>GET //subpath/anothersubpath HTTP/1.1
</code></pre>

<p>Notice the two slashes in the GET request. In the VirtualService spec <code>rewrite.uri</code> field, I can't seem to leave that field empty or add an empty string there. Doing so causes the resource not to validate.</p>

<p>I.e. I can NOT do this:</p>

<pre><code>    rewrite:
      uri: ""
</code></pre>

<p>And can NOT do this</p>

<pre><code>    rewrite:
      uri:
</code></pre>

<p>How can I define a VirtualService rewrite to send traffic to the root of the destination service? Any help is much appreciated. </p>

<p>There is a github <a href="https://github.com/istio/istio/issues/8076" rel="noreferrer">issue</a> about this.</p>

<p>The simplest fix is to add whitespace in the <code>uri</code> as long as You are not running <code>.net</code> core application.</p>

<pre><code>    rewrite:
      uri: " "
</code></pre>

<p>Other workaround can be found <a href="https://github.com/istio/istio/issues/8076#issuecomment-448738814" rel="noreferrer">here</a>, </p>

<p>Hope it helps.</p>
