"Por dos semanas" or "durante dos semanas"?
That's a good question!
Let's see the differences between these two options bit by bit:
If you say "por una semana" and "durante una semana" both will be understood with the same meaning, as "por" is pretty common now.
Por is a preposition and durante is an adverb, we use adverbs to describe actions, in this case saying for how long the action goes for.
What to use? The third option
Officially, por used for duration is not official and it seems to be an anglicism, and usually when you hear people using "por" for duration they're not native speakers.
The ideal is using EITHER durante, which is the only word that actually means "during" , OR NOTHING, which is maybe the most common:
Estuve allí durante cuatro horas / Estuve allí dos horas
If you can remember, use "durante" or nothing before saying the duration, cause it sounds better and it's the only one with evidence to support it, especially in formal writing.
Aaaand specially if you can still break the habit.
Lots of people with advanced level use "por" and in those cases is so difficult to break the habit, so if you have tried and think you can't, then it's worth considering if it's really worth all the work, as it's not a barrier for understanding.
But as I said, if you're in time, I'd try to say "viajé durante dos semanas" or "viajé dos semanas" as much as possible.
Hope that helps!