To remove mildew stains, sponge rugs and carpets with a thick, dry soap or detergent suds and wipe them clean with a damp cloth. You could also clean them with an electric shampooing machine.
If the problem is excess water (e.g., flooding due to burst pipes or washer overflow) the procedure is somewhat different. Immediate action is important to keep mildew from starting up. First, determine how much water has been absorbed by the carpet. To check, raise a portion of the carpet by pulling it off the installation strips at one corner. If the pad is wet, the entire carpet and pad will have to be removed. This is necessary so the sub-floor can dry, which in many cases prevents it from buckling.
When both carpet and pad have been saturated, the best recommendation is to have a professional pick up the carpet and transport it to the plant, where it can be cleaned, deodorized and dried. Some shrinkage should be expected (one to two inches). However if the carpet backing is in good repair, it can be re-stretched to fit the room by a power stretcher.
If professional services are not available, it is possible to dry a saturated carpet at home. Using a hot water extraction unit, vacuum the carpet until no more water can be removed. Then place the carpet on a flat surface outside in the fresh air and sunshine. It is important to turn the rug or carpet upside down so that, as the carpet dries, any soil in the carpet backing or along the carpet fibers will be drawn toward the surface of the carpet rather than the base.
Once the sub-flooring has dried, the dry pad and carpet can then be re-installed. If a musty odor is present in the padding, it is best to replace it. Do not re-install the padding, thinking that in time the odor will disappear. Once the carpet is placed over the musty odor, the problem will only get worse, since the moisture cannot readily escape. Musty carpet can be deodorized by professional cleaners.
If only the carpet is wet, (padding and sub-flooring are dry) a hot water extraction vacuum may be sufficient to remove the water. These units can be rented from rental agencies, and hardware and grocery stores. Do not attempt to use a home vacuum unless it is specifically designed as a wet vacuum.