# How do you make a Kubernetes Ingress Path with a wildcard or regex in the middle?

**URL:** <https://community.traefik.io/t/how-do-you-make-a-kubernetes-ingress-path-with-a-wildcard-or-regex-in-the-middle/16671>\
**Category:** Traefik v2\
**Tags:** kubernetes-ingress\
**Created:** [November 30, 2022, 7:20pm UTC](https://community.traefik.io/t/how-do-you-make-a-kubernetes-ingress-path-with-a-wildcard-or-regex-in-the-middle/16671 "2022-11-30T19:20:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blazefire](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Blazefire](https://community.traefik.io/u/Blazefire)\
**Post date:** [November 30, 2022, 7:20pm UTC](https://community.traefik.io/t/how-do-you-make-a-kubernetes-ingress-path-with-a-wildcard-or-regex-in-the-middle/16671/1 "2022-11-30T19:20:58Z")

</div>

Sorry this has probably been asked a million times and in the documentation but I can't seem to find the answer. I have a url endpoint with a unique UUID in the middle so how do I route that path in my Kubernetes ingress router. For example a path like this `api/foo/123-aad-1123-abc/bar` needs to be routed but for all uuids and the uuid needs to be provided to the microservice

Here is my Kubernetes ingress yaml. What would I need to update the path to get this to work?:

```auto
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/router.entrypoints: "web"
    traefik.ingress.kubernetes.io/router.tls: "false"
    traefik.ingress.kubernetes.io/router.middlewares: default-traefik-header@kubernetescrd
  name: traefik
spec:
  rules:
    - host: "localhost"
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: webapp
                port:
                  name: webapp
          - path: "Foo/*/bar"
            pathType: Prefix
            backend:
              service:
                name: api
                port:
                  name: api

```

Thanks for any help in advance

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 1, 2022, 7:30am UTC](https://community.traefik.io/t/how-do-you-make-a-kubernetes-ingress-path-with-a-wildcard-or-regex-in-the-middle/16671/2 "2022-12-01T07:30:57Z")

</div>

[A similar question](https://community.traefik.io/t/help-converting-nginx-ingress-with-regex-to-traefik-v2/15680) has been asked before, sadly without an answer.

---

<div class="post-metadata">

**Author:** ![hlascelles](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@hlascelles](https://community.traefik.io/u/hlascelles)\
**Post date:** [September 2, 2024, 4:53pm UTC](https://community.traefik.io/t/how-do-you-make-a-kubernetes-ingress-path-with-a-wildcard-or-regex-in-the-middle/16671/3 "2024-09-02T16:53:40Z")

</div>

I've done a writeup on how this works for us. [Allow configuring rule syntax with Kubernetes Ingress annotation by rtribotte · Pull Request #10985 · traefik/traefik · GitHub](https://github.com/traefik/traefik/pull/10985#issuecomment-2325092572)

I suspect if you changed

- path: "Foo/\*/bar"  
to something like one of these (I don't know how many times you will have to escape the slashes)
- path: '/{regex:(foo/.\*/bar)}'
- path: '/{regex:(foo/.\*/bar)}'
- path: '/{regex:(foo\/.\*\/bar)}'

it might work. Note if you are on traefik 3.x you will have to pass in some command line switches.
