Drink lots of water, and never hold in the pee! If you need to pee, pee.
Stay away from spicy, salty and sugary foods. Do not wear tight underwear/trousers. I found that the trousers I wore for work were the cause of my UTI, as I was fine when I was at home, but would start feeling it coming once I was in uniform.
There's debate on if Cranberry juice/pills work, but it's worth a try. Some cranberry juices are too sugary though, you'd have to be careful with brands. And check your antibiotics first, but my doctor told me to take the antibiotics and some ibuprofen for the pain.
p.s. This is all advice that my doctor gave me and it really helped, so it's worth following!