Anas (may Allah be pleased with him) narrated that the Prophet ﷺ forbade a man from raising his eye towards the sky while observing Salat. He ﷺ said: “How is it that some people raise their eyes towards the sky during Salat.” That is, what is the matter with them? Why are they raising their eyes towards the sky? Let them refrain from this or else they will lose their sight.
This threat indicates that it is prohibited for a person to raise his eye towards the sky while observing Salat. I have seen someone when he rises from the Rukoo' and says: ‘Allah hears the one who praises Him’, he would then raise his eyes and face (upward). It is impermissible for anyone to do this. Indeed, some scholars, may Allah shower blessings on them, state that the Salat of the one who does this is invalid because he has committed a forbidden act: a prohibition that is specific to Salat. A Shariah principle states that: “Whosoever commits anything that is specifically forbidden in an act of worship, his worship is null and void.”
Then, these scholars also justify their view with a second reason. They say: This is a bad manner towards Allah – the Mighty and Sublime. What is required from an individual in the course of the Salat is concentration and humility; thus, he should lower his head.
They also bring another justification: A person is ordered to face the Qiblah with all his body. If he raises his face towards the sky, his face will be facing towards the sky and not the Qiblah, which nullifies his Salat. The issue is grievous. Accordingly, the statement of Prophet ﷺ was emphatic regarding this issue; he ﷺ said: “Let them refrain or else they will lose their sight.”
If someone were to ask: Now where do I place my head? We reply:
You should fix your gaze at your point of prostration except when you raise your index finger for Tashahud. At this instance, you should look at the index finger because the Prophet ﷺ would not move his eyes beyond its movement when he raises it.
Some scholars make an exception to looking at the Imam in order to follow him. This is more important if the person cannot hear the Imam and it is not possible for him to follow him as his Imam except he looks at him. This is because the companions used to do this. The Prophet ﷺ would ascend the Minbar and pray on it, and say: "I did that so that you will follow me and know your Salat." It was not possible for them to have learnt the Salat without looking at him.
Some scholars exempt a person who observes his Salat in front of Ka'bah in the Masjid Al-Haram; they opine that such person should look at the Ka'bah. However, this exemption is weak. The correct opinion is that he should not look at the Ka'bah during Prayer because this has not been reported from the Prophet ﷺ. This is because that could cause confusion whereby he will be looking at the people circumambulating the House.
Then, the statement of some of them that looking at the Ka'bah is an act of worship is a blunder. It is not correct. It has not been reported from the Prophet ﷺ as far as I know, through an authentic or weak hadeeth, that looking at the Ka'bah is an act of worship.
Allah alone grants success.