أَخْبَرَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، قَالَ أَنْبَأَنَا حَمَّادُ بْنُ مَسْعَدَةَ، عَنْ حُمَيْدٍ، عَنْ ثَابِتٍ، عَنْ أَنَسٍ، قَالَ رَأَى النَّبِيُّ صلى الله عليه وسلم رَجُلاً يُهَادَى بَيْنَ رَجُلَيْنِ فَقَالَ ‏"‏ مَا هَذَا ‏"‏ ‏.‏ قَالُوا نَذَرَ أَنْ يَمْشِيَ إِلَى بَيْتِ اللَّهِ ‏.‏ قَالَ ‏"‏ إِنَّ اللَّهَ غَنِيٌّ عَنْ تَعْذِيبِ هَذَا نَفْسَهُ مُرْهُ فَلْيَرْكَبْ ‏"‏ ‏.‏
Translation
It was narrated that Anas bin Malik said

"The Messenger of Allah came to a man who was being supported by two others and said: 'What is the matter with him?' It was said: 'He vowed to walk to the Ka'bah.' He said: 'Allah does not benefit from his torturing himself.' And he told him to ride."