The `$hdr(...)` is a variable for getting values based on generic header structure `Name: value`, it does not uderstand the specifics of each header and what could be as `value`.
For you case, you should use `$hfl(...)`:
- https://www.kamailio.org/wikidocs/cookbooks/5.8.x/pseudovariables/#hflname-h...
If not getting what you need, probably the best is to discuss on mailing list to see what options are to resolve your needs.