كتاب المغازى
64  
Military Expeditions led by the Prophet (pbuh) (Al-Maghaazi)
(80)
Chapter: The dismounting of the Prophet (saws) at Al-Hijr
(80)
باب نُزُولُ النَّبِيِّ صلى الله عليه وسلم الْحِجْرَ
Sahih al-Bukhari 4419

Narrated Ibn `Umar:

When the Prophet (ﷺ) passed by Al-Hijr, he said, "Do not enter the dwelling places of those people who were unjust to themselves unless you enter in a weeping state lest the same calamity as of theirs should befall you." Then he covered his head and made his speed fast till he crossed the valley.

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ الْجُعْفِيُّ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، أَخْبَرَنَا مَعْمَرٌ، عَنِ الزُّهْرِيِّ، عَنْ سَالِمٍ، عَنِ ابْنِ عُمَرَ ـ رضى الله عنهما ـ قَالَ لَمَّا مَرَّ النَّبِيُّ صلى الله عليه وسلم بِالْحِجْرِ قَالَ ‏ "‏ لاَ تَدْخُلُوا مَسَاكِنَ الَّذِينَ ظَلَمُوا أَنْفُسَهُمْ، أَنْ يُصِيبَكُمْ مَا أَصَابَهُمْ إِلاَّ أَنْ تَكُونُوا بَاكِينَ ‏"‏‏.‏ ثُمَّ قَنَّعَ رَأْسَهُ وَأَسْرَعَ السَّيْرَ حَتَّى أَجَازَ الْوَادِيَ‏.‏
Reference : Sahih al-Bukhari 4419
In-book reference : Book 64, Hadith 441
USC-MSA web (English) reference : Vol. 5, Book 59, Hadith 703
  (deprecated numbering scheme)