I have a cat that has been having peeing issues for years now and I still don't know what the problem is!! Here are some things I've learned either on my own or from some research as my vet either wants to put my cat on behavior meds or prescription cat food which is way too expensive!! But cats associate pain with the litterbox after having a UTI so it can be a hard habit to break.
-Wash the litter box. The smell can over time get imbeded into the plastic which will cause it to smell all the time no matter how frequently you clean it. You might even want to consider buying a new one if it's been a long time since it's been replaced. Cats also like soft things to pee on so maybe going to a clumping litter if you don't already would help.
-Drench the carpet with a 25/75 vinegar water mix and let it set for a few minutes then use a carpet shampooer to suck it up and rinse it with plain water. The vinegar will help cut the smell out of the carpet and hopefully the cat won't go back to that area to remark it. Or find the smell bad and stop using that spot.
-Move the box to another location and see if he uses it there and then slowly move it back to the spot you want it. Or give him a choice and add a second box some place else.
-Switch foods to something for urinary healthy. Pro Plan (found at pet stores) makes a dry food and so does Purina easily found at walmart. Friskies makes a low ash/magnesium canned food (marked special diet on the label) . Magnesium is one of the issues that can cause UTIs and crystals in cats. I've also learned that dry food is really bad for cats as they don't get enough water in their diet which can cause these problems too. I've just recently switched to the Friskies special diet food and my cat that has been having problems is a totally different cat now!! She is social, more loving and hasn't peed on anything in almost 2 weeks (knocking on wood!). They don't seem to car for the Pro Plan cat food so I'm going to try the Purina Urinary one next. If they don't like it them I'm going to stick with Iams hairball.
Oh, and he could still have the UTI too. There is this crystal stuff you can buy at the pet store that is supposed to turn blue when they pee on it if it detects anything in their urine.
Good luck!!
S.-Mommy to 2 cats and 2 kids :)