If you’ve ever had a urinary tract infection, then you know—in the infamous words of Jersey Shore’s Snooki who came down with a UTI last month—it hurts like balls.You get a UTI when bacteria get stuck inside your urethra and travel up to your bladder. If you don’t treat it (which seems too painful to imagine), it can move up to your kidneys, causing a more serious infection.UTIs are the second leading cause of lost work time for women (after painful periods) and half of all women in the United States will battle a UTI in her lifetime. They can range from just plain uncomfortable to excruciating, but any woman who gets one wants to get rid of it—fast.MORE: UTIs Fact and FictionBut you don’t have to wind up like Snooki, downing cranberry juice and gritting your teeth through the pain. Like anything else, prevention is the best medicine. Here are four ways to keep these nasty infections at bay:Pee after sex.You probably wonder every time you dutifully head to the bathroom after sex: Do I really need the post-coital pee? The answer is yes, you do. “You are flushing away bacteria that might have gotten pushed up into the urethra during sex,” explains Sophie Fletcher, M.D., director of research at the Methodist Center for Restorative Pelvic Medicine in Houston, Texas.For the same reason, Fletcher recommends drinking plenty of water during the day. “This is important to flush the bladder free of bacteria that can lead to a UTI,” she explains. Basically, she wants you to pee—a lot.Take a cranberry supplement.Cranberries have a reputation as the UTI cure-all for a reason: They contain a type of flavanol called proanthocyanidin (or PAC) that stops bacteria from sticking to your urinary tract so it gets flushed out before an infection begins. You can use cranberries when you feel an infection coming on or when you want to prevent one (like after sex, if that’s a trigger for you), but you should talk to your doc if you already feel a full-blown infection.Instead of guzzling cranberry juice (which is usually loaded with sugar), try taking a supplement. Not all are created equal, so we recommend ellura, which is the only cranberry supplement available in the US that has enough PAC (36 mgs) in a single dose to actually help fix the problem.Wipe from front to back.Not to get too graphic here, but one of the best ways to prevent a UTI is to make sure you always wipe from front to back after you go to the bathroom. You wouldn’t want any, you know, cross-contamination.QUIZ: Do You Have a Healthy Lifestyle?“The most common UTI-causing bacteria is E. coli,” explains Fletcher. “That bacteria comes from the rectum, so wiping from front to back gets E. coli out of range of the bladder.” And while you’re at it, make sure you’re totally dry because running around with damp undies can just make a UTI (and life in general) worse.Avoid bubble baths. We love a relaxing bubble bath as much as the next person, but sitting in that sudsy water just invites bacteria into your body. “You want to avoid moist environments in the vaginal area,” says Fletcher. Think: Baths (bubbly or not), hot tubs or wet bathing suits. If you want to unwind at the end of the day, your best bet is a hot shower, a pair of warm, dry pajamas and a generous glass of Merlot.