Hadithcore
Mishkat al-Masabih, 997

He reported God’s Messenger as saying, “Sonny, avoid turning to the side when you are engaged in prayer, for turning to the side produces destruction. If you must do it, do it in the voluntary, but not in the obligatory prayer.” Tirmidhi transmitted it.

وَعَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «يَا بُنَيَّ إِيَّاكَ وَالِالْتِفَاتَ فِي الصَّلَاةِ فَإِنَّ الِالْتِفَاتَ فِي الصَّلَاةِ هَلَكَةٌ. فَإِنْ كَانَ لابد فَفِي التَّطَوُّع لَا فِي الْفَرْضِيَّة» . رَوَاهُ التِّرْمِذِيّ

References1 variant
In-Book Reference
Book 4, Hadith 417