title: HTTP404 for resources when using url rewriting on Istio gateway
body: <p>I'm trying to deploy a service to a specific url address on AKS. The following yaml let's me access the service at desired address, like xxxx.europe.cloudapp.azure.com/service-a. This works great, i've managed to hide the entire service under desired url:</p>
  
  <pre><code>apiVersion: networking.istio.io/v1alpha3
  kind: Gateway
  metadata:
    name: istio-gateway
  spec:
    selector:
      istio: ingressgateway
    servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
      - "*"
  ---
  apiVersion: networking.istio.io/v1alpha3
  kind: VirtualService
  metadata:
    name: istio
  spec:
    hosts:
    - "*"
    gateways:
    - istio-gateway
    http:
    - match:
      - uri:
          prefix: /service-a
      rewrite:
        uri: /    
      route:
      - destination:
          host: service-a.default.svc.cluster.local
  </code></pre>
  
  <p>However when the welcome page is displayed, i only see text. No css/javascript/image files are loaded. Everything that this page is trying to load still has original url address without any rewriting being made by my gateway configuration. So the home page requests this:</p>
  
  <pre><code>http://xxxxx.europe.cloudapp.azure.com/icon.jpg
  </code></pre>
  
  <p>instead of this:</p>
  
  <pre><code>http://xxxxx.europe.cloudapp.azure.com/service-a/icon.jpg
  </code></pre>
  
  <p>What is the best way to handle rewriting urls for resources and links on a page? Do i have to manually change the urls on a home page?</p>
  
  <p>EDIT:</p>
  
  <p>To be more clear.</p>
  
  <ol>
  <li>Rewriting of the url works as expected, the address is exactly how i want (the entire service is hidden under "xxxx.europe.cloudapp.azure.com/service-a".</li>
  <li>Once i enter the "xxxx.europe.cloudapp.azure.com/service-a" i see service's welcome page, but without any css/jpegs/js loaded. Also the links visible on the welcome page don't work. </li>
  <li>for example, "icon.jpg" is not loaded. Page wants to load it from <a href="http://xxxx.europe.cloudapp.azure.com/icon.jpg" rel="nofollow noreferrer">http://xxxx.europe.cloudapp.azure.com/icon.jpg</a> but it's not there anymore. Due to rewriting it's available at <a href="http://xxxx.europe.cloudapp.azure.com/service-a/icon.jpg" rel="nofollow noreferrer">http://xxxx.europe.cloudapp.azure.com/service-a/icon.jpg</a> which is as expected.</li>
  </ol>
  
  <p>I kind of expected that the <a href="http://xxxx.europe.cloudapp.azure.com/icon.jpg" rel="nofollow noreferrer">http://xxxx.europe.cloudapp.azure.com/icon.jpg</a> request will be automatically rewritten to <a href="http://xxxx.europe.cloudapp.azure.com/service-a/icon.jpg" rel="nofollow noreferrer">http://xxxx.europe.cloudapp.azure.com/service-a/icon.jpg</a>. But obviously i was mistaken. So i wonder how i can handle the links within the service itself in a manageable way - i mean i can modify every possible link within the app, but what if we change the url again (from /service-a to /service-b). The service is written with ASP.NET Core, i will look for some kind of internal rewriting solution that is maintainable.  </p>