Try washing them with detergent, a cup or two of vinegar and a cup of baking soda. Then wash them again with just regular detergent. Works for me.
The worse the odor the more baking soda I use. I dissolve it in water first. Sometimes if the first washes don't work, DRY THEM then repeat the process. For some reason drying them seems to stop the mildew smell then allows it to be washed out.