ומ"ש אבל פירש שגמלוהו וכו' בפר' אע"פ פירש לאחר כ"ד חודש וחזר כיונק שקץ וכמה אמר שמואל ג' ימים וכתב הרא"ש ירושלמי ר' אבהו בשם ריב"ל ג' ימים מע"ל בד"א שפירש מתוך בוריו אבל פירש מתוך חליו מחזירין אותו כשאינו של סכנה אבל של סכנה אפי' אחר כמה ימים מחזירין אותו והרי"ף כתב ירושלמי זה אלא שלא סיים בו לחלק בין של סכנה לאינו של סכנה וכן עשה הרמב"ם בפרק ג' מהמ"א ונראה שהטעם מפני שהוא דבר פשוט דכשיש סכנה מחזירין דהא אין לך דבר שעומד בפני פקוח נפש: ודע שהרמב"ם כתב בפרק הנזכר כלשון הזה יונק תינוק והולך אפי' ד' או ה' שנים ואם גמלוהו ופירש ג' ימים או יותר מחמת בוריו לא מחמת חליו אינו חוזר ויונק והוא שגמלוהו אחר כ"ד חדש. אבל גמלוהו בתוך זמן זה אפי' חדש או שנים מותר לחזור ולינק עד סוף כ"ד חדש. ומשמע מדקדוק לשונו דהא דאמרינן דיונק והולך ד' וה' שנים היינו דוקא בשלא פירש כלל אבל אם פירש תוך כ"ד חדש אף ע"פ שהוא מותר לחזור ולינק אינו מותר לינק אלא עד סוף כ"ד חדש דוקא ומילתא דסברא הוא אבל איני יודע מהיכן למד הרב כן : "And what he wrote, 'But if he has weaned, etc.' —
In the chapter Even HaEzer (in Ketubot 60a), it is explained that after 24 months, if the child returns to breastfeeding, it is as if he is consuming something detestable. And how long [after weaning] is it considered detestable? Shmuel said, three days. The Rosh wrote that the Yerushalmi [states]: Rabbi Abbahu said in the name of Rabbi Yehoshua ben Levi, three days is the limit.
When is this said? When the child was weaned while healthy. But if he was weaned due to illness, he can return to breastfeeding unless it is a matter of danger, in which case even after several days, he can return to breastfeeding. The Rif also cited this Yerushalmi but did not conclude with a distinction between a case of danger and one without danger. The Rambam in Chapter 3 of Hilchot Ma’achalot Asurot did similarly. It seems that the reason is because it is obvious that in a case of danger, the child can return to breastfeeding, as there is nothing that stands in the way of preserving life.
Note that the Rambam wrote in the aforementioned chapter as follows: A child can nurse for even four or five years. But if he was weaned for three days or more due to his health, and not because of illness, he should not return to breastfeeding, provided that he was weaned after 24 months. But if he was weaned within this period, even if it was for a month or two, he is permitted to return to breastfeeding until the end of 24 months.
From his precise language, it seems that when it is said that a child can nurse for four or five years, this only applies if he was never weaned at all. However, if he was weaned within 24 months, although he may return to nursing, he is only permitted to nurse until the end of 24 months. This reasoning is logical, but I do not know from where the Rambam derived this."