When Pharaoh let the people go, God did not lead them on the road through the Philistine country, though that was shorter. For God said, “If they face war, they might change their minds and return to Egypt.” 18 So God led the people around by the desert road toward the Red Sea.
Exodus 13:17-18 NIV
Then the LORD said to Moses, 2 “Tell the Israelites to turn back and encamp near Pi Hahiroth, between Migdol and the sea. They are to encamp by the sea, directly opposite Baal Zephon. 3 Pharaoh will think, ‘The Israelites are wandering around the land in confusion, hemmed in by the desert.’ 4 And I will harden Pharaoh’s heart, and he will pursue them. But I will gain glory for myself through Pharaoh and all his army, and the Egyptians will know that I am the LORD.”
Exodus 14:1-4 NIV