When the Prophet ﷺ passed by al-Hijr, he said, "Do not enter the dwellings of those who wronged themselves, lest there befall you what befell them, unless you are weeping." Then he covered his head and quickened his pace until he had crossed the valley.
لما مر النبي ﷺ بالحجر قال: لا تدخلوا مساكن الذين ظلموا أنفسهم، أن يصيبكم ما أصابهم، إلا أن تكونوا باكين، ثم قنع رأسه وأسرع السير حتى أجاز الوادي.
Bukhari narrated it in the Book of Military Expeditions (4419), and Muslim in the Book of Asceticism (2980:39), both of them through Zuhri, from Salim bin Abdullah, from Abdullah bin Umar, who narrated it. The wording given is that of Bukhari.His saying, "at Hijr," refers to the dwellings of Thamud.