Now the Philistines had taken the ark of God, and they brought it from Ebenezer to Ashdod.
Apparently, the reason for the Philistines' taking the ark of God to Ashdod was the location there of a principal temple of Dagon.  Samson had destroyed the one at Gaza  (Judges 16), so they by-passed Gaza on the way to Ashdod.