I would start with a vet check and be sure he does not have a UTI. I'm not sure why you think you can tell by what he does outside, whether or not he has a UTI; that is just not possible.

Once a male starts marking, from the online research I have done, it is a life long thing. You can start using belly bands, as this will save your carpets, furniture and sanity! You can make them or buy them. I get mine from this site: www.pawstoadmire.com She has lots of fabric to choose from. I recommend you have a minimum of 3: one on the dog, one in the wash, and one in the closet ready to go on the dog. There will be times, especially at the beginning, when the band gets wet, until YOU get used to the band and how often you need to check it.

My Willy is a marker, so he always had a band on in the house. He is the only male here.

A belly band is a piece of fabric which wraps around the dog and closes with velcro. You put in a Poise pad (do not use a sanitary napkin, those are made for a different type of fluid). One theory is that the dog feels a more dominant dog has a leg over his back, so he does not pee. Another theory is that the dog isn't free to pee the way he wants to. I don't know / care about the theory I just need a clean home! LOL You dog can develop diaper rash just as a baby, so you need to check the pad and change it regularly. And of course you remove the belly band when the dog goes outside.