“R. Yitzĥak stated: One must visit his rabbi on the three pilgrimage festivals” (RH 16b). This is in order to strengthen his connection to the rabbi, as a result of which he will strengthen his commitment to Torah and mitzvot. It is very fitting on the holy days to strengthen one’s connection with those who are bearers of Torah. Indeed, it is an age-old custom to do so, as we see from the words of the Shunamite woman’s husband. When he saw his wife setting off to see Elisha the Prophet on a weekday, he asked: “Why are you going to him today? It is neither New Moon nor Shabbat” (2 Melakhim 4:23). This implies that on Rosh Ĥodesh and Shabbat she did go to see the prophet (the current equivalent of whom would be the rabbi).
The Rishonim explain that the precise parameters of this mitzva depend upon geography. If one lives far away from his rabbi, he must visit him at a minimum on the three festivals, as R. Yitzĥak stated. One who lives nearer by should visit him at least once a month. One who lives very close must visit him every Shabbat (based on Rabbeinu Ĥananel and Ritva; see BHL 301:4 s.v. “lehakbil”). Based on this, the custom nowadays is to go over to the local rabbi at the end of prayers and wish him “Shabbat Shalom.” It would seem that those who go to hear the rabbi’s drasha are also counted among those who go to visit him.
Zvi Yehuda Kook explained that even though women are not obligated to study all of the details and minutiae of Torah, their general attitude toward Torah and those who study it is better than that of men. It is a fact that before the Torah was given at Sinai, God commanded Moshe to address the women first and only afterward the men, as it is written, “Thus shall you say to the house of Yaakov and declare to the children of Israel” (Shemot 19:3). “The house of Jacob” refers to the women, while “the house of Israel” refers to the men (Mekhilta).
It is not by chance then that the mitzva of visiting one’s rabbi on Shabbat and holidays is derived from the actions of the Shunamite woman. For, it would seem that the general attitude of women toward Torah is deeper than that of the men. The men occupy themselves more with the details of the laws and commandments of the Torah, while women connect more with the overall spirit of the Torah (Peninei Halakha: Women’s Prayer ch. 3 and 7:2).