<p>I have a avi Kubernetes ingress and want to redirect / to /ui . Is it possible to do on Ingress routing rules.</p>
<p>poc.xxx.com/ --&gt; How to redirect it to poc.xxx.com/ui</p>
<p>poc.xxx.com/ui --&gt; ui-service</p>
<p>poc.xxx.com/backend --&gt; backend-service</p>
<p>My ingress Yaml</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: poc-ingress
spec:
  rules:
    - host: poc.xxx.com
      http:
       paths:
       - path: /ui
         pathType: Prefix
         backend:
           service:
            name: ui-service
            port: 
             number: 443
       - path: /backend
         pathType: Prefix
         backend:
           service:
            name: backend-service
            port:
             number: 443
</code></pre>

<p>What if you do something like this, any request at <code>/</code> will get moved to <code>ui</code> service</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: poc-ingress
spec:
  rules:
    - host: poc.xxx.com
      http:
       paths:
       - path: /
         pathType: Prefix
         backend:
           service:
            name: ui-service
            port: 
             number: 443
       - path: /backend
         pathType: Prefix
         backend:
           service:
            name: backend-service
            port:
             number: 443
</code></pre>
<p>However still if you are looking for a redirect solution you can follow below option</p>
<p>Add this annotation in ingress :</p>
<pre><code>nginx.ingress.kubernetes.io/server-snippet: |
      location ~ / {
         rewrite / https://test.example.com/ui permanent;
      }
</code></pre>
<p>if request comes at <code>/</code> it will get redirected to another domain or <code>ui</code> path as you wish.</p>
<p>You can also create the two ingress looks like this, first one check <code>backend</code> and <code>/</code> while another one handles <code>ui</code> :</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: poc-ingress
  annotation:
    nginx.ingress.kubernetes.io/server-snippet: |
      location ~ / {
         rewrite / https://test.example.com/ui permanent;
      }
spec:
  rules:
    - host: poc.xxx.com
      http:
       paths:
       - path: /backend
         pathType: Prefix
         backend:
           service:
            name: backend-service
            port:
             number: 443
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ui-ingress
spec:
  rules:
    - host: poc.xxx.com
      http:
       paths:
       - path: /ui
         pathType: Prefix
         backend:
           service:
            name: ui-service
            port: 
             number: 443
</code></pre>
<p>Do not forget to use the ingress class annotation in ingress.</p>
