Heavily soiled carpet is best cleaned with a special carpet cleaning machine that can be purchased or rented from most home improvement stores. Carpet cleaners usually use very hot water and a soap or other chemical solution, which is injected into the carpet and then suctioned back out. The hot water kills bacteria and lifts out dirt while the soap removes stains and spots.
Before cleaning the carpet with hot water, go over the carpet with a broom and then vacuum thoroughly. This removes crumbs, pet hair and other small particles. Large stains can be pre-treated with ammonia, a vinegar and water mixture or with lemon juice and salt.
Test the stain remover on an unobtrusive area of the carpet before applying to the stain, to make sure the mixture will not damage the carpet. After applying, leave the stain remover for 15 to 20 minutes before blotting with a towel and allowing to dry. Finally, run the carpet cleaner with very hot water and a cleaning solution.
In place of the commercial solutions sold with the carpet cleaning machine, more ammonia or vinegar mixed in water can be used. Allow the carpet to dry for 4 to 6 hours before walking on it.