A lot of fruit fly traps are designed to attract male fruit flies and dispose of them. This one is however designed to attract the female fruit fly which is the one that actually attacks the fruit. This was originally on Gardening Australia
2 plastic drink bottles
1 teaspoon of vanilla essence
1 tablespoon of ammonia or bleach
1 cup of water
Leave the lid screwed on one of the drink bottles, remove the lid from the other and then cut it off at the shoulder.
Make a hole in the body of the intact bottle the same size as the neck of the one that has ben cut and place it into the hole like a funnel.
The cup shape that remains exposed will be the entrance to the trap. Mix the water vanilla essence and bleach together and pour the solution through the hole. Hang the trap from a tree near tomatoes or other plants.
The mixture of the vanilla esence and water will attract the fruit fly into the bottle from which they cannot escape.
They will be killed by the bleach or ammonia.