Introduction
The Gemara in Berachos (29b) teaches:אמר רבי יעקב אמר רב חסדא כל היוצא לדרך צריך להתפלל תפלת הדרך, מאי תפלת הדרך? ״יהי רצון מלפניך ה׳ אלקי, שתוליכני לשלום, ותצעידני לשלום, ותסמכני לשלום, ותצילני מכף כל אויב ואורב בדרך, ותשלח ברכה במעשי ידי, ותתנני לחן לחסד ולרחמים בעיניך ובעיני כל רואי, ברוך אתה ה׳ שומע תפלה״ – Rabbi Yaakov said that Rav Chisda said: Anyone who sets out on a journey must recite the traveler’s prayer. What is the formula for the traveler’s prayer? The Gemara answers: “May it be Your will, Lord my G-d, to lead me to peace, direct my steps to peace, and guide me to peace, and rescue me from the hands of any enemy or ambush along the way, and send blessing to the work of my hands, and let me find grace, kindness, and compassion in Your eyes and in the eyes of all who see me. Blessed are You, Lord, Who hears prayer.”
The above is brought down l’halachah in the Shulchan Aruch (Orach Chaim 110:4). However, the Rambam makes no mention of the obligation to recite Tefillas HeDerech, and all he writes is (Hilchos Berachos 10:25): “When one enters into a village who should daven, and after he leaves he should daven”, as is clear from Berachos (60a). He also writes in Hilchos Tefillah (4:19): “If one is traveling in a dangerous place, where there are bandits, robbers and wild animals, and the time for davening arrives, one should daven one berachah,צרכי עמך ישראל מרובין ודעתן קצרה וכו' – “The needs of Your nation, Yisrael, are many and their intelligence is limited etc.”
The Beis Yosef (110) already asks why the Rambam omits the halachah of reciting Tefillas HaDerech. The Pri Chodosh (s.k. 4) answers the Rambam and explains that Tefillas HaDerech is the same tefillah as the short tefillah the Rambam brings to daven at a time of danger. (However, see the Rishon LeTziyon, Berachos 29b, where the Orach Chaim HaKadosh argues on this, and offers a different explanation).