I saw awhile back the idea of using a paper funnel in a bottle to make a trap for fruit flies. Later I decided to 3D print cones to do the job better.
Put fruit (Banana peels seem to work best) in a bottle, then put one of these on top. Secure it in place with either glue, tape, or cut a hole in the bottle cap and screw it over the trap.
Fruit flies go in and cannot get out.