If the cat has recently urinated on the carpet, first absorb as much of the cat urine as possible using paper towels or an old towel. Place clean paper towels over the cat urine area and tread on them so as to absorb as much of the urine as possible. Repeat with dry towels until no more moisture can be absorbed.
Areas of cat urine that have dried and previously gone undetected can be found with the aid of a black light. The cat urine stains will fluoresce under the ultra violet light in a darkened room. Hand held black lights are quite inexpensive, usually costing between $15 - $25. To save the expense of a black light you can always use your nose to detect the source of the odor.
Next, wet the area with a solution of 50% white vinegar and 50% water. Make sure you use enough of the solution to penetrate the fibers deep down.
After the vinegar treatment dry off the carpet as much as possible. You can assist drying by blotting with paper towels as described above. If you own a wet/dry vacuum extractor use that to remove excess moisture.
Apply a handful of baking soda over the affected area and drizzle it with a quarter of a cup of hydrogen peroxide mixed with a teaspoon of liquid dishwashing detergent. (not caustic detergent that you put in a dishwasher) Work it in with a scrubbing brush or your fingers (be sure to wear rubber gloves) to dissolve the baking soda and work it down well into the carpet. Allow it to dry. Once dry the baking powder will vacuum up easily taking all the odors with it.