[Machine] Allah ﷺ read a verse during the year of Fath (the year of the conquest of Makkah) that required prostration. So, all the people, including those who were riding and those who were kneeling on the ground, prostrated. It is mentioned about Ali and Ibn Zubayr that they prostrated while they were riding by means of a gesture. Ibn Umar was asked about prostrating on an animal, to which he replied, "Prostrate and say 'awm'." Al-Zuhri said, "Do not prostrate unless you are in a state of purity. So, if you prostrate while you are in a state of presence (in the sense that you are not going anywhere), face the qibla (the direction of the Kaaba), but if you are riding, then it does not matter where your face is."
اللهِ ﷺ قَرَأَ عَامَ الْفَتْحِ سَجْدَةً فَسَجَدَ النَّاسُ كُلُّهُمْ مِنْهُمُ الرَّاكِبُ وَالسَّاجِدُ فِي الْأَرْضِ حَتَّى إِنَّ الرَّاكِبَ يَسْجُدُ عَلَى يَدِهِ وَيُذْكَرُ عَنْ عَلِيٍّ وَابْنِ الزُّبَيْرِ ؓ أَنَّهُمَا سَجَدَا وَهُمَا رَاكِبَانِ بِالْإِيمَاءِ وَعَنِ ابْنِ عُمَرَ أَنَّهُ سُئِلَ عَنِ السُّجُودِ عَلَى الدَّابَّةِ فَقَالَ اسْجُدْ وَأَوْمِ وَقَالَ الزُّهْرِيُّ لَا تَسْجُدْ إِلَّا أَنْ تَكُونَ طَاهِرًا فَإِذَا سَجَدْتَ وَأَنْتَ فِي حَضَرٍ فَاسْتَقْبِلِ الْقِبْلَةَ وَإِنْ كُنْتَ رَاكِبًا فَلَا عَلَيْكَ حَيْثُ كَانَ وَجْهُكَ