<p>I create a ingress by this example:</p>
<pre><code>$ echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
spec:
  ingressClassName: nginx
  rules:
  - host: my.hostname.com
    http:
      paths:
      - path: /something(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: http-svc
            port: 
              number: 80
' | kubectl create -f -
</code></pre>
<p>But if I go to <code>my.hostname.com/something</code> the route is not matched, even if I changed it to</p>
<pre><code>$ echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: rewrite
spec:
  ingressClassName: nginx
  rules:
  - host: my.hostname.com
    http:
      paths:
      - path: /something
        pathType: Prefix
        backend:
          service:
            name: http-svc
            port: 
              number: 80
' | kubectl create -f -
</code></pre>
<p>The route pass me to <code>http-svc</code> but the <code>rewrite</code> is not working.</p>
<p>So how can I do a complex rewrite which <code>haproxy.router.openshift.io/rewrite-target: / </code> can not provide?</p>

PaleNeutron
<p>OpenShift routers aren't based on nginx, so nginx annotations/rules aren't going to do anything. If the <a href="https://docs.openshift.com/container-platform/4.11/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration" rel="nofollow noreferrer">builtin HAProxy based functionality</a> doesn't meet your needs, you'd have to either <a href="https://github.com/nginxinc/nginx-ingress-operator/blob/main/docs/nginx-ingress-controller.md" rel="nofollow noreferrer">install an nginx based ingress controller</a> or handle the rewrite at the application level.</p>
