The Messenger of Allah ﷺ said, "Whoever sets out in pursuit of knowledge is in the path of Allah until he returns."
حدثنا نصر بن علي قال حدثنا خالد بن يزيد العتكي عن أبي جعفر الرازي عن الربيع بن أنس
قال رسول الله ﷺ من خرج في طلب العلم كان في سبيل الله حتى يرجع
[Its isnad is daif]. Tabarani narrated it in Saghir (1/136) from the hadith of Nasr bin Ali with the same wording, and Munziri indicated that it is hasan in Targhib wal-Tarhib (1/105).Rabi, Abu Jafar, and Khalid are all narrators whose hadith is hasan elsewhere, though this narration was criticized regarding him. However, Ibn Hibban said, in the biography of Rabi bin Anas, "People avoid his hadith when it comes through the narration of Abu Jafar from him, because it contains much confusion" (Thiqat 4/228).