The Messenger of Allah ﷺ prayed two rakahs when he traveled and four when he was resident.Ibn Abbas said, "Whoever prays four rakahs while traveling is like one who prays only two rakahs while resident."Ibn Abbas also said, "The prayer was shortened only once, when the Messenger of Allah ﷺ prayed two rakahs and the people each prayed only one rakah."
حدثنا مروان بن معاوية أخبرنا حميد بن علي العقيلي حدثنا الضحاك بن مزاحم
صلى رسول الله ﷺ حين سافر ركعتين وحين أقام أربعا قال قال ابن عباس فمن صلى في السفر أربعا كمن صلى في الحضر ركعتين قال وقال ابن عباس لم يقصر الصلاة إلا مرة واحدة حيث صلى رسول الله ﷺ ركعتين وصلى الناس ركعة ركعة