Intermittent issues with URL redirection

Hi

I'm running traefik v1.7 on docker swarm. Below are the labels on my traefik container.

"traefik.app-redirect.frontend.redirect.permanent": "true",
"traefik.app-redirect.frontend.redirect.regex": "^https://[^/]+/(.*)",
"traefik.app-redirect.frontend.redirect.replacement": "https://test.com/$1",
"traefik.app-redirect.frontend.rule": "Host:example.com,www.example.com"

So, the expected behaviour is,

example.com is expected to be redirected to https://test.com/

But, 3 out of 6 times I try to hit the URL https://example.com/, the resultant URL is being redirected to,

https://test.com/example.com and since this path is invalid, it results in 404 error.

Any ideas on how to check this further?

The last release of Traefik v1 was in 2021 (link), you should really update. No bug fixes and security fixes for over 2 years.

If you still want to move on, please format your code with 3 backticks before and after, or select and use </> button.

thank you @bluepuma77 . Updated the original description. I agree that the running version is very old. However I'm trying to resolve this intermittent issue first as this is impacting the application.

I think the $ in label needs to be escaped. This works in v2 and v3:

- traefik.http.middlewares.mywwwredirect.redirectregex.regex=^https://www\.(.*)
- traefik.http.middlewares.mywwwredirect.redirectregex.replacement=https://$${1}

From simple Traefik example.

thank you for the response.

but I'm not really sure if that fits to my use case? apologies if I did miss anything.

regex would match with any host.

So if I test the regex expression that I mentioned in my initial post, I can see that the regex is correctly replacing the host, but when this is in live, I sometimes see the redirection is not working as expected.