<p>i want to redirect domain in nginx ingress kubernete.</p>

<pre><code>https://test.example.io/preview/qLxiVcDGxCaQ134650121853FTg4
</code></pre>

<p>if in url <code>preview</code> comes change domain redirect </p>

<pre><code>https://test.app.example.io/preview/qLxiVcDGxCaQ134650121853FTg4
</code></pre>

<p>what i was trying</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    certmanager.k8s.io/cluster-issuer: staging
    nginx.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: nginx
  name: staging-ingress
spec:
  rules:
  - host: test.example.io
    http:
      paths:
      - path: /
        backend:
          serviceName: service-1
          servicePort: 80
      - path: /preview/*
        backend:
          url: 
          serviceName: service-2
          servicePort: 80
  tls:
  - hosts:
    - test.example.io
    secretName: staging
</code></pre>

<p>for simple nginx block is like </p>

<pre><code>location ~ /preview
    {
      rewrite /preview https://test.app.example.com$uri permanent;
    }
</code></pre>

Harsh Manvar
<p>My logic thinking, try it : </p>

<pre><code>metadata:
      annotations:
        nginx.ingress.kubernetes.io/configuration-snippet: |
         rewrite /preview https://test.app.example.com$uri permanent;

spec:
      rules:
      - host: test.example.io
        http:
          paths:
          - path: /
            backend:
              serviceName: service-1
              servicePort: 80
      - host: test.app.example.io
        http:
          paths:
          - path: /preview/*
            backend:
              serviceName: service-2
              servicePort: 80
</code></pre>

<p>Hope it works ! </p>

<p>On code above: You should not access using: <a href="https://test.app.example.io/preview/" rel="noreferrer">https://test.app.example.io/preview/</a> (It just be redirected link ) at all.</p>
