Pour club soda or white wine on the stain as soon as you see it. The carbonation in the club soda will begin to lift the wine from the carpet. White wine neutralizes red wine contents and makes it easier to remove from the carpet. These are more effective if applied when the spill is fresh.
Blot as much of the liquid up as you can with a clean cloth or paper towel. Be gentle and blot, don't rub, or you will push the wine further into the carpet fibers. The stain won't be gone, but club soda or white wine will will prevent the stain from setting until you can remove it.
Pour salt over the stain and let it sit overnight while the stain is still wet. The salt will turn pink as the carpet absorbs it and it works to lift the red pigment from the carpet. Let it sit for at least six hours or overnight, and then vacuum. This may be enough to remove the stain.
Dilute one teaspoon of ammonia in one cup of warm water and apply to the stain if it's still there. Apply enough so that the spot is wet. Let the solution sit on the carpet for five to 10 minutes, and then blot carefully with clean cloths.