Depending upon how badly it got wet you have a couple of options. Take it to a specialty car wash where they clean the carpets of cars. Or replace the carpet.
I had a van leak during the rainy season and there was so much water in the carpet it actually started growing. This was AFTER I'd gotten 6 gallons of water out of it with my Bissel carpet cleaner. It was still just SOAKED. And I had tried leaving the doors open when it wasn't being driven, cranking the heater, even taking it to a car wash that had the foam carpet cleaner stuff. Didn't work. The only thing I didn't do was take it to like one of the detailer type places that cleans carpets. They might have been able to get the water and the smell out. But I'm not really sure.
I eventually just sold the van with the information that the carpet was completely ruined and would have to be replaced.