Mishkat al-Masabih 334
عَنْ أَبِي أَيُّوبَ الْأَنْصَارِيِّ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِذَا أَتَيْتُمُ الْغَائِطَ فَلَا تَسْتَقْبِلُوا الْقِبْلَةَ وَلَا تَسْتَدْبِرُوهَا وَلَكِنْ شَرِّقُوا أَوْ غَرِّبُوا» قَالَ الشَّيْخ الإِمَام محيي السّنة C: هَذَا الْحَدِيثُ فِي الصَّحْرَاءِ وَأَمَّا فِي الْبُنْيَانِ فَلَا بَأْس لما رُوِيَ:
From Abu Ayyub al-Ansari, who said: The Messenger of Allah ﷺ said: "When you go to relieve yourselves, do not face the qiblah nor turn your backs to it, but face east or west." The Shaykh, the Imam Muhyi as-Sunnah, may Allah have mercy on him, said: This hadith is about the open country; as for inside buildings, there is no harm, because of what has been narrated: