Hi Iuri!
I don’t believe it’s possible to manipulate the host/domain via Caddyfile currently (such as identifying and removing the www. as you require). rewrite operates on the URI, and redir has no regex functionality.
This would probably require extending Caddy itself.