Moed Katan 15b: A mourner is forbidden to bathe, as it says, “Do not anoint with oil” (Shmuel II 14:2) – and bathing is included in anointing.
Yoreh Deah 381:1. Rema: By law, this is only forbidden during shiva, but the custom today is to forbid bathing for the whole shloshim. And we should not change this custom, since it is an old custom, established by great rabbis.
מועד קטן טו ע”ב: אבל אסור ברחיצה, דכתיב (שמואל ב׳ י״ד) ואל תסוכי שמן, ורחיצה בכלל סיכה.
יו”ד סימן שפא,א: רחיצה כיצד, אסור לרחוץ כל גופו אפילו בצונן, אבל פניו ידיו ורגליו בחמין אסור בצונן מותר, ואם היה מלוכלך בטיט וצואה רוחץ כדרכו ואינו חושש: הגה וכל זה מדינא אינו אסור רק שבעה אבל אח״כ מותר ברחיצה אלא שנהגו האידנא לאסור כל רחיצה כל ל׳ יום ואפי׳ לחוף הראש אסור ואין לשנות המנהג כי מנהג קדום הוא ונתייסד על פי ותיקין.
One day in 1876, a guest was sitting with R’ Yitzchok Elchonon Spector, when a man came in and asked, “Rabbi, I am a mourner. Am I permitted to go to the bathhouse?” Without hesitation, he answered him, “You are permitted.”
The questioner was not satisfied with this instant response, and spoke again: “Rabbi, I am in mourning for my father.” “Permitted, you are permitted,” the rav answered, using a double expression.
But this still did not settle the mind of the questioner, who asked a third time, “Only to sweat, or even to wash in hot water?” The rav answered him with a friendly smile, but also with surprise: “I just told you that you are permitted, and I said it without adding any details or qualifications. If so, go without delay, before I change my mind!”
After the man left, the rav looked at the guest, noticing his amazement, and guessing his thoughts. How and why could he rule leniently, contrary to the ruling of the Rema, who cites an enactment of the early rabbis? He said jokingly, “My guest will go on his way and tell people that the head of the Beis Din of Kovno gives hasty, mistaken rulings.” The guest also responded in jest, “Certainly I will.”
“If so,” said the rav, “let me ask you: do you know the Maharshal’s reason for forbidding bathing?” The guest answered: “Because of the prohibition against having a haircut; for the usual way is to have a haircut in the bathhouse.” “In that case,” continued R’ Yitzchok Elchonon, “why are we allowed to bathe during Chol Hamoed? That is also a period when we are forbidden to have a haircut! I know that this is the problem posed by the Taz on Yoreh Deah 381:1, and he answers that since everyone is forbidden to have a haircut then, we do not worry that one might forget.” He smiled, “Here too, today is one of the days of Sefiras Haomer, when the custom is to forbid haircuts. So why would this man forget and get a haircut? Therefore, he is allowed to bathe.
“I urged the questioner to go immediately, because it looked like he wanted to argue against my ruling. He wanted to object that the prohibition on haircuts during Chol Hamoed is a real Rabbinic prohibition, while during Sefirah it is only a minhag. I did not want to enter into a detailed discussion with him, so I did not point out to him that the prohibition against bathing in hot water after shivah is also only a minhag.”
Source: Mourning in Halacha, p. 211
[His last point is that the questioner could have objected that perhaps people will take the minhag of Sefirah lightly and get haircuts in the bathhouse during Sefirah. R’ Yitzchok Elchonon’s response is that the minhag not to bathe during shloshim was not set up for such people who take minhagim lightly, because then why would they respect this minhag in the first place? Rather the “minhag vasikin” brought by the Rema was aimed at carefully observant Jews, and such people would never come to take a haircut in Sefirah.]