Pee before and after sex. In addition, wash thoroughly after sex. Also wash thoroughly after number 2 (not sex related, but prevents bacteria from traveling) whenever possible. This is from someone who used to get them chronically and no longer does.