Redirect link in Traefik v2.4.9

Hi.
Im new to traefik v2.
I want to redirect a request from localhost:37001/proxy/ping to localhost 37000/api/ping. What am I doing wrong?

static file (config.toml)

[Global]
checkNewVersion = true

[log]
  level = "DEBUG"
  filePath = "log-file.log"

[accessLog]
  filePath =  "log-access.log"
  bufferingSize =  100

[providers]
  [providers.file]
    filename = "config-dynamic.toml"

[api]
  dashboard = true
  debug = true

[entryPoints]
  [entryPoints.web]
    address = ":80"

  [entryPoints.websecure]
    address = ":443"

  [entryPoints.dashboard]
    address = ":8080"

  [entryPoints.port1]
    address = ":37001"

dynamic file (dynamic-config.toml)

[http]
    [http.routers]
       [http.routers.my-router]
          rule = "Host(`www.example.com`)"
          service = "phx"
          entryPoints = ["web-secure"]
       [http.routers.my-router.tls]
          certResolver = "sample"

  [http.middlewares]
    [http.middlewares.test-redirectregex.redirectRegex]
      regex = "^http://localhost:37001/proxy/(.*)"
      replacement = "http://localhost:37000/api/${1}"

Hi @tonton

You have define the middleware but the router is not referencing it.
You want a line in your router like
middlewares = test-redirectregex