Haircuts on Chol Hamoed

The Shulchan Aruch (O.C. 531:1) writes that there is a mitzvah to get a haircut on erev yom tov. The Pri Megadim is unsure if the mitzvah is that one should ensure his hair looks its best in honor of yom tov, or perhaps there is only a mitzvah to get a haircut if one’s hair is somewhat overgrown and he definitely needs one.
If one did not get a haircut before yom tov, he may not get one on chol ha’moed. This is true even though one could correctly argue that getting a haircut qualifies as a yom tov need. Nevertheless, the Sages forbade getting a haircut on chol ha’moed.
The prohibition applies to shaving as well. Still, Rav Moshe Feinstein, zt”l, ruled that in case of great need, someone who shaves every day, who is in a place where other people likewise shave every day, may shave even on chol ha’moed. But even if someone relies on this leniency, he still may not get a haircut. The Shulchan Aruch clearly writes, however, that a mustache was not included in the decree. One may freely trim his mustache on chol ha’moed, even if his only intention is for vanity.