The Prophet ﷺ said, "The farther one walks to the mosque, the greater the reward."
حدثنا مسدد حدثنا يحيى عن ابن أبي ذئب عن عبد الرحمن بن مهران عن عبد الرحمن بن سعد
عن النبي ﷺ قال الأبعد فالأبعد من المسجد أعظم أجرا
[Sahih]. Ibn Majah reported it in the chapter on masjids, section on "the one farther away has greater reward," hadith no. 782, from the hadith of Ibn Abu Dhib, through this route. Hakim graded it sahih (1/208), and Dhahabi agreed with him. Ibn Mulaqqin graded it hasan in Tuhfat al-Muhtaj (1/432, hadith nos. 498, 499). It is also found in the Musnad of Imam Ahmad (1/68), and it has a corroborating witness in Sahih Muslim (662).