Two year old hits

My two year old son hits but only me. I have tried time out, not doing anything at all, walking away, I feel like if there’s something I could have tried I have tried it. The only time he stops is if my husband is home and all he has to do is look at him and he stops. I’m a stay at home mom so during the day he does it and I’m at my wits end. If anybody has any ideas or this happens/happened to you I am open to suggestions.