Language:
كتاب الصلاة
8  
Prayers (Salat)
(18)
Chapter: (It is permissible) to offer Salat (prayer) on roofs, a pulpit or wood
(18)
باب الصَّلاَةِ فِي السُّطُوحِ وَالْمِنْبَرِ وَالْخَشَبِ
Sahih al-Bukhari 378

Narrated Anas bin Malik:

Once Allah's Messenger (ﷺ) fell off a horse and his leg or shoulder got injured. He swore that he would not go to his wives for one month and he stayed in a Mashruba [??] (attic room) having stairs made of date palm trunks. So his companions came to visit him, and he led them in prayer sitting, whereas his companions were standing. When he finished the prayer, he said, "Imam is meant to be followed, so when he says 'Allahu Akbar,' say 'Allahu Akbar' and when he bows, bow and when he prostrates, prostrate and if he prays standing pray, standing. After the 29th day the Prophet (ﷺ) came down (from the attic room) and the people asked him, "O Allah's Messenger (ﷺ)! You swore that you will not go to your wives for one month." He said, "The month is 29 days."

حَدَّثَنَا مُحَمَّدُ بْنُ عَبْدِ الرَّحِيمِ، قَالَ حَدَّثَنَا يَزِيدُ بْنُ هَارُونَ، قَالَ أَخْبَرَنَا حُمَيْدٌ الطَّوِيلُ، عَنْ أَنَسِ بْنِ مَالِكٍ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم سَقَطَ عَنْ فَرَسِهِ، فَجُحِشَتْ سَاقُهُ أَوْ كَتِفُهُ، وَآلَى مِنْ نِسَائِهِ شَهْرًا، فَجَلَسَ فِي مَشْرُبَةٍ لَهُ، دَرَجَتُهَا مِنْ جُذُوعٍ، فَأَتَاهُ أَصْحَابُهُ يَعُودُونَهُ، فَصَلَّى بِهِمْ جَالِسًا، وَهُمْ قِيَامٌ فَلَمَّا سَلَّمَ قَالَ ‏"‏ إِنَّمَا جُعِلَ الإِمَامُ لِيُؤْتَمَّ بِهِ، فَإِذَا كَبَّرَ فَكَبِّرُوا، وَإِذَا رَكَعَ فَارْكَعُوا، وَإِذَا سَجَدَ فَاسْجُدُوا، وَإِنْ صَلَّى قَائِمًا فَصَلُّوا قِيَامًا ‏"‏‏.‏ وَنَزَلَ لِتِسْعٍ وَعِشْرِينَ فَقَالُوا يَا رَسُولَ اللَّهِ إِنَّكَ آلَيْتَ شَهْرًا فَقَالَ ‏"‏ إِنَّ الشَّهْرَ تِسْعٌ وَعِشْرُونَ ‏"‏‏.‏
Reference : Sahih al-Bukhari 378
In-book reference : Book 8, Hadith 30
USC-MSA web (English) reference : Vol. 1, Book 8, Hadith 375
  (deprecated numbering scheme)