While attempting to create a regex redirect I continue to run into an error condition. The regex is valid outside of the Docker/Traefik YAML file. However, always returns an error related to the '.' character.
The complete middleware clause is as follows:
- "traefik.http.middlewares.test-redirectregex.redirectregex.regex=^(?:www.)?(.+)
If I double the backslashes the issue disappears, but the results suffer.
The missing quote was a typo when copying the string into forum.
As for the missing backslash, it appears to be an issue with the forum. If I return to edit my original post the backslash is there between the www and the '.'.
I used regex101 to validate my expressions. Here is the decode provided:
`
^(?:www.)?(.+)
`
^ asserts position at start of the string
Non-capturing group
(?:www.)?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
www matches the characters www literally (case sensitive)
. matches the character . literally (case sensitive)
1st Capturing Group
(.+)
.+
matches any character (except for line terminators)
Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)