This is such an age old pet-owner question! The challenge is to use a good cleaning/anti-smell agent that won't harm you carpet. I have had good results from Anti Icky Poo...got to love the name. It is important to follow the directions and be aware that if you don't get all the smell out the cat may pee there again.
They make special carpet cleaner specified for animals. You can find this at your local pet store and or at your local home improvement store. You can also use soap and water, let the soap and water soak and then scrub the cat urine with a rag. Repeat process if needed.
Janitorial supply stores have enzyme sprays... they smell bad also.. and require repeated spraying. Enzymes are the way to go.. Then use a product called Simple Green. It is a fantastic cleaner for just ablot everything.