Sahih Muslim Book 6, Hadith 12
The Messenger of Allah (ﷺ) said four rak'ahs in the noon prayer while at Medina, but he offered two rak'ahs in the afternoon prayer at Dhu'l-Hulaifa.
I fell ill and lbn 'Umar came to inquire after my health, and I asked him about the glorification of Allah (i. e. prayer) while travelling. Thereupon he said: I accompanied the Messenger of Allah (ﷺ) on a journey but I did not see him glorifying Him, and were I to glorify (Him). I would have completed the prayer. Allah, the Exalted, has said:" Verily there is a model pattern for you in the Messenger of Allah."
I observed four rak'ahs in the noon prayer with the Messenger of Allah (ﷺ) at Medina, and said two rak'ahs in the afternoon prayer at Dhu'l-Hulaifa.