Traefik redirect from one url to url with prefix

Hello guys. We decided to move from subdomain structure to one root domain with path prefixes, but we got many old urls in the internet . So is there any way to add redirect from old url to new one?
For example,
we got subdomain test.example.com switched to example.com/test, i can access correctly site with string in docker yaml file
traefik.frontend.rule: Host:example.com;PathPrefixStrip:/test, but when im trying to add to traefik config
redirects like

[http.middlewares]
  [http.middlewares.test-redirectregex.redirectRegex]
    regex = "^https://(*).example.com/)"
    replacement = "^https://example.com/${1}"

traefik says that it doesn't know where to forward this request
If im trying to add traefik.frontend.rule: Host:test.example.com,example.com;PathPrefixStrip:/test
traefik adds prefix to both hosts. Is there anyway to resolve this without adding second reverse proxy?

Hello

middlewares are only in Traefik v2.