When the Prophet ﷺ passed by al-Hijr, he said, "Do not enter the dwellings of those who wronged themselves unless you are weeping, lest there befall you what befell them." Then he covered his face with his cloak while seated on his mount.Wazad in another narration, "Then he covered his head and hastened his pace until he had crossed the valley."
أن النبي ﷺ لما مر بالحجر قال: لا تدخلوا مساكن الذين ظلموا أنفسهم إلا أن تكونوا باكين أن يصيبكم ما أصابهم ثم تقنع بردائه وهو على الرحل. وزاد في رواية: ثم قنع رأسه وأسرع السير حتى أجاز الوادي.
Bukhari narrated it in the Chapters of the Prophets (3380), and Muslim in Zuhd (2980:39), both from the hadith of Zuhri, who said, Salim bin Abdullah informed me, from his father, and he mentioned it. The addition was reported by Bukhari in Maghazi (4419) from Abdullah bin Muhammad Jafi, who said, Abdul-Razzaq narrated to us, Mamar informed us, from Zuhri, from Salim, from Ibn Umar, and he mentioned it. This is Bukhari's wording.Muslim's wording is, "From Ibn Shihab, mentioning Hijr, the dwellings of Thamud, Salim bin Abdullah said, Abdullah bin Umar said, 'We passed with the Messenger of Allah ﷺ by Hijr...'" and he mentioned it, and in it, "for fear that what befell them should befall you as well," then he rebuked them and hastened on until he had passed beyond it.