That he (the Holy Prophet, sal Allahu alayhi wa sallam) said:"When you go to the privy, neither turn your face nor your back towards the qiblah at the time of excretion or urination, but turn towards the east or the west. (Abu Ayyub said): When we came to Syria, we found that the toilets already built there were facing the qiblah, We turned our faces away from them and begged pardon of Allaah.
إِذَا أَتَيْتُمُ الْغَائِطَ فَلاَ تَسْتَقْبِلُوا الْقِبْلَةَ بِغَائِطٍ وَلاَ بَوْلٍ وَلَكِنْ شَرِّقُوا أَوْ غَرِّبُوا فَقَدِمْنَا الشَّامَ فَوَجَدْنَا مَرَاحِيضَ قَدْ بُنِيَتْ قِبَلَ الْقِبْلَةِ فَكُنَّا نَنْحَرِفُ عَنْهَا وَنَسْتَغْفِرُ اللَّهَ