What you'll need is this:
$HTTP["host"] =~ var.mdomainregexredir {
$HTTP["scheme"] =~ ".*" { # catch http and https
# %0 references the above matched pattern (http or https)
# also changed to just catch the whole path and redirect using it with $0
url.redirect = ( ".*" => "%0://www.varmdomain$0" )
}
}
Unless you have a compelling reason, I'd be redirecting everything to https. You can do the https and www redirects all as one too.