<p>I am using istioingress gateway. How can I redirect non-www traffic to www?</p>

<pre><code>    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
    name: my-gateway
    namespace: some-config-namespace
    spec:
    selector:
        app: my-gateway-controller
    servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
        hosts:
        - uk.bookinfo.com
        - eu.bookinfo.com
        - www.uk.bookinfo.com
        - www.eu.bookinfo.com
        tls:
        httpsRedirect: true # sends 301 redirect for http requests
    - port:
        number: 443
        name: https-443
        protocol: HTTPS
        hosts:
        - uk.bookinfo.com
        - eu.bookinfo.com
        - www.uk.bookinfo.com
        - www.eu.bookinfo.com
        tls:
        mode: SIMPLE # enables HTTPS on this port
        serverCertificate: /etc/certs/servercert.pem
        privateKey: /etc/certs/privatekey.pem
</code></pre>

<p>Currently, I am able to access the website using both endpoints. But, I want to redirect all traffic from non-www to www.</p>

<p>Have you tried <code>redirect</code> feature of Istio?</p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: server-vs
spec:
  hosts:
  - mysite.com
  gateways:
  - my-gateway
  http:
  - match:
    - uri:
        exact: /
    redirect:
      uri: /
      authority: www.mysite.com
</code></pre>

<p>Also you could have done the redirection at DNS level. But I think some domain providers don't support it. Godaddy, for example, does.</p>
