<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>

RNK
<p>Istio Gateway receives the traffic, and the routing from there will be handled by VirtualService configuration. For your non-www to www traffic routing, the same question was raised in Istio discussion forum, so that may be of your help.</p>

<p><a href="https://discuss.istio.io/t/simply-redirecting-non-www-to-www/3370" rel="nofollow noreferrer">https://discuss.istio.io/t/simply-redirecting-non-www-to-www/3370</a></p>

<p>As to getting all the traffic, you may want to use a wildcard in the <code>hosts</code> definition in the Gateway configuration (ref: <a href="https://istio.io/docs/reference/config/networking/gateway/#Server" rel="nofollow noreferrer">https://istio.io/docs/reference/config/networking/gateway/#Server</a>).</p>
