Let houseplant soil dry out between watering. This prevents dampness that can attract flies as well as gnats and other insects.
Trap fruit flies by filling an open cup with old wine: the flies mistake this for food and get trapped by surface tension.
Put vinegar in a water bottle with the top cut off, turn the top over to form a funnel, and this will trap the insects inside.
Other homemade traps can be baited with decaying fruit, wine, fruit juice, or apple cider vinegar. These can be effective against fruit flies, but make sure that the trap is set up to ensure that they’ll drown inside instead of feeding off the bait. Mix a few drops of dish soap with any liquid bait you choose to get rid of surface tension. The flies will slip right into the mixture and won’t be able to get out.
Don’t forget the classic fly swatter. You can buy them for as low as $1 at drugstores, and they’re always handy to have around. Using a fly swatter is one of the messier methods of treatment, but luckily flies are so small and easy to clean up. Fly swatters do come in different shapes and sizes, so it’s still a good idea to read up on the best fly swatters. These days, there are also electric swatters that make it easier to kill flies as they’re flying.