I just moved to an apartment and the carpet smells real bad
Just tell the owner to get you new carpet
Get it washed by a professional or rent a machine. You could also mask the smell with all the freshners..They dont get rid of it they just hide it.
Shampoo the carpet, or use 409 it works great, but make sure you dont mask the carpet with something that you think smells good because it would make it smell worse.
Try and get the owner to replace the carpet or at least pay to have it professionally cleaned. Do-it-yourself steam cleaners do not work nearly as well as the professional cleaners can get it. if all that fails, go rent a Rug doctor and do it yourself, but like I said it will not work as well. Also, try and find out if there is a particular location for the smell as it could be mildew or something like that in a certain area of the apartment. you could even have a leaky pipe causing it to smell bad. BTW, if this is a basement apartment, it might be a damp smell from being underground.
It all depends on the source of the odor. If it is something like urine, rotting food or anything else organic, I recommend Nature's Miracle. The enzymes in it break it down and neutralize it. You can get it at pet supply stores. My second choice would be Odo-Ban. They sell this at Sam's. Just follow the directions for best results.