Vinegar does not keep fruit flies away; in fact, vinegar can actually attract flies. Vinegar with acetic acid will invite fruit flies into a person's kitchen, yet vinegar can also be used to eliminate a pesky fruit fly problem.
Vinegar flies, which are commonly called fruit flies, typically find overripe fruit with ease. This is because they have odor receptors that target smells associated with rotting fruit, like acids. The acids from overripe fruits drift in the air and attach themselves to olfactory receptors on the fruit flies. Based on those smells, the fruit flies are then able to target and find their possible food sources. Vinegar that has a fruit base, like apple cider vinegar or red wine vinegar, can help trap and kill fruit flies.
Consumers can kill fruit flies in their own kitchen with minimal work. The first step is to fill a small container with apple cider or red wine vinegar. Fruit flies will happily be attracted this liquid without drowning, so another substance needs to be added. To break the surface of the vinegar, a tiny amount of dish soap is necessary. The dish soap has surfactants, which are compounds that lower surface tension. The fruit flies will be attracted to the sweet smells of the vinegar, but will get sucked down because of the tension created by the dish soap.
Consumers can also trap the flies by placing a funnel in a clean wine bottle or jar, and then adding a teaspoon of apple cider or red wine vinegar to it. The flies can easily fly in, but will have a difficult time getting out.