How do I utilize variables in rules?

Ok, that seems to have worked to put $HOSTNAME$ into both fields.

If I only put it into the virtual host, I still got the error.
I could put the actual hostname in virtualhost and it worked fine.

Works
$HOSTNAME in both hostname and vhost fields of the rule
Service check command check_mk_active-http!’–ssl’ ‘–onredirect=follow’ ‘–sni’ ‘$HOSTNAME$’ ‘$HOSTNAME$’

I put the actual hostname into the vhost in the rule
Service check command check_mk_active-http!’–ssl’ ‘–onredirect=follow’ ‘–sni’ ‘$HOSTNAME$’ ‘www..com’

Didn’t work before but is now working (or maybe I had a typo, now I’m questioning myself)
This is only with $HOSTNAME$ in the vhost field in the rule
check_mk_active-http!’–ssl’ ‘–onredirect=follow’ ‘–sni’ ‘$_HOSTADDRESS_4$’ ‘$HOSTNAME$’