As best I recall, the rule is based on pronunciation, not on spelling. So for words where the "h" is pronounced, you treat it as a consonant and lead with "a": "go for a hike." Whereas for words where "h" is silent, so pronunciation thus leads with a vowel, you lead with "an": "it would be an honor."
"Historic" is pronounced differently, mostly based on region. You can go to "a historic occasion," with hard H, or "an 'istoric occasion," with a soft one.
Or, for native speakers: type what you'd pronounce.
Is that a rule in American English? I don't remember hearing it in school.