Have you actually tested positive for a UTI or do you "just" have symptoms of one? It's possible that what you're feeling is superficial irritation of your uretha. you might train a pain reliever like Uristat if that's the case.

If you are actually getting UTIs from spinning, I'd second the Vitamin C. Wear clean shorts and get out of them as soon as you're done with class. Empty your bladder before and after class.

I have recurring UTIs but they're not from cycling. The same preventions apply. You want to discourage the bacteria from
moving up your uretha to your bladder and to create an inhospitable environment for the bacteria, either with antibiotics, Vitamin C or cranberry. Take then at bedtime for the best results.