My final code after all of the optimization:
public class WwwRedirectionMiddleware
_https_port: do not use underscores in variable names etc., except at the start.
_https_port = 80; The HTTPS port is most definitely not port 80.
The logic to fill redirectUrl and then redirect is duplicated. It should be a method that gets called. I'd move the "compile new host value in these specific cases" logic to a method and ...