Sayyiduna Ibn Umar (may Allah be pleased with them both) narrated: I entered the house of Sayyidah Hafsah (may Allah be pleased with her), and my glance happened to fall, and I saw the toilet of the Messenger of Allah (peace and blessings be upon him) facing the qiblah.
(b) Sayyiduna Abu Hurayrah (may Allah be pleased with him) said: "When one of you comes to relieve himself, he should neither face the qiblah nor turn his back to it."
(c) Al-Sha'bi (may Allah have mercy on him) said: Both spoke the truth. The statement of Abu Hurayrah (may Allah be pleased with him) concerns the open desert, for Allah has servants, angels and jinn, who pray there, so one should neither face them nor turn one's back to them when relieving oneself or urinating in the desert; as for their toilets, they are houses in which there is no qiblah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 442