Rewrite-middleware breaks all routes

Hi!
I have traefik config in my docker-compose file which routes traffic between several apps and I'd like to add a middleware to app-main to forward all www.hostname requests to hostname. I've added the following lines

      - "traefik.http.middlewares.cutwww.redirectregex.regex=^https?://(?:www\\.)?(.+)"
      - "traefik.http.middlewares.cutwww.redirectregex.replacement=https://$${1}"
      - "traefik.http.middlewares.cutwww.redirectregex.permanenttrue"

nearby line 80 and enabled this middleware in line 83 with

- "traefik.http.routers.${APP_NAME}-main.middlewares=traefik-compress,cutwww" 

After that, all my working routes to app-main have stopped to work (error 404). Please point me what's wrong in this config

You are missing a = in your label

I think this might refer to the 1. match in parenthesis, maybe it needs to be 2.

Use your browser’s developer tools’ networking tab to see what’s happening.

yep, thanks - now it works better
http:// localhost --> https:// localhost
https:// localhost renders correct page
http:// www.localhost --> https:// www.localhost
but https:// www.localhost still 404-not-found (i've tried both ${1} and ${2})