The Location of the Cave
Allah tells;
وَتَرَى الشَّمْسَ إِذَا طَلَعَت تَّزَاوَرُ عَن كَهْفِهِمْ ذَاتَ الْيَمِينِ
And you might have seen the sun, when it rose, declining to the right from their cave, and when it set, turning away from them to the left, while they lay in the midst of the cave.
This indicates that the entrance to the cave faced north, because Allah tells us that when the sun was rising, sunlight entered the cave
ذَاتَ الْيَمِينِ
(the right),
meaning that the shade decreased towards the right, as Ibn Abbas, Sa`id bin Jubayr and Qatadah said;
تَّزَاوَرُ
(declining) means leaning.
Every time the sun rises on the horizon, its rays decline until there is nothing left in such a place when it reaches its zenith.
So Allah said,
وَإِذَا غَرَبَت تَّقْرِضُهُمْ ذَاتَ الشِّمَالِ
and when it set, turning away from them to the left,
meaning, it entered their cave from the left of its entrance, which means from the west.
This proves what we say, and it is clear to anyone who thinks about the matter and has some knowledge of astronomy and the paths of the sun, moon and stars. If the entrance of the cave faced east, nothing would have entered it when the sun set, and if it faced the direction of the Qiblah (in this case, south), nothing would have entered it at the time of sunrise or sunset, and the shadows would have leaned neither to the right nor the left. If it had faced west, nothing would have entered it at the time of sunrise, until after the sun had passed its zenith, and would have stayed until sunset. This supports what we have said, and to Allah is the praise.
Ibn Abbas, Mujahid and Qatadah said that "turning away from them" means,
that it would shine on them and then leave them.
Allah has told us this, and He wants us to understand it and ponder its meaning, but He did not tell us the location of this cave, i.e., in which country on earth it is, because there is no benefit for us in knowing that, and no legislative objective behind it. If there was any spiritual or religious interest that could be served by our knowing that, Allah and His Messenger would have taught us about it, as the Prophet said;
مَا تَرَكْتُ شَيْيًا يُقَرِّبُكُمْ إِلَى الْجَنَّةِ وَيُبَاعِدُكُمْ مِنَ النَّارِ إِلاَّ وَقَدْ أَعْلَمْتُكُمْ بِه
I have not left anything that will bring you closer to Paradise and keep you further away from Hell but I have certainly taught you about it.
So Allah has told us about the features of the cave, but He did not tell us where it is, and He said,
وَتَرَى الشَّمْسَ إِذَا طَلَعَت تَّزَاوَرُ عَن كَهْفِهِمْ
And you might have seen the sun, when it rose, declining from their cave.
Malik narrated from Zayd bin Aslam, "Leaning."
ذَاتَ الْيَمِينِ وَإِذَا غَرَبَت تَّقْرِضُهُمْ ذَاتَ الشِّمَالِ
وَهُمْ فِي فَجْوَةٍ مِّنْهُ
the right, and when it set, turning away from them to the left, while they lay in the midst of the cave.
meaning, the sun entered the cave without touching them, because if it had touched them, it would have burnt their bodies and clothes.
This was the view of Ibn `Abbas.
ذَلِكَ مِنْ ايَاتِ اللَّهِ
That is from the Ayat of Allah,
how He guided them to this cave where He kept them alive, and the sun and wind entered the cave preserving their bodies. Allah says,
ذَلِكَ مِنْ ايَاتِ اللَّهِ
(That is from the Ayat of Allah).
Then He says;
مَن يَهْدِ اللَّهُ فَهُوَ الْمُهْتَدِي
He whom Allah guides, he is the rightly-guided;
meaning that He is the One Who guided these young men to true guidance among their people, for the one whom Allah guides is truly guided,
وَمَن يُضْلِلْ فَلَن تَجِدَ لَهُ وَلِيًّا مُّرْشِدًا
but he whom He sends astray, for him you will find no guardian to lead him.
and the one whom Allah leaves astray will find no one to guide him