title: k8s ingress nginx set rewrite-target per domain
body: <p>Is it somehow possible to add different rewrite targets per domain in an ingress?</p>
  
  <p>I have an ingress that looks like this:</p>
  
  <pre><code>apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: multiple-domains-ingress
    annotations:
      nginx.ingress.kubernetes.io/rewrite-target: /entry1/$1
  spec:
    rules:
      - host: domain1.com
        http:
          paths:
            - path: /(.*)
              backend:
                serviceName: my-service
                servicePort: 8080
  </code></pre>
  
  <p>It would be nice if I could add multiple paths with different redirects like this:</p>
  
  <pre><code>apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: multiple-domains-ingress
  
  spec:
    rules:
      - host: domain1.com
        http:
          paths:
            - path: /(.*)
              backend:
                serviceName: my-service
                servicePort: 8080
                redirect: /entry1/$1
  
      - host: domain2.com
        http:
          paths:
            - path: /(.*)
              backend:
                serviceName: my-service
                servicePort: 8080
                redirect: /entry2/$1
  </code></pre>
  
  <p>Or do I have to create a new ingress for every domain?
  Also If there are any best practices I'm violating here I'd be happy to hear about it :-)</p>
  
  <p>Thanks</p>