UTI antibiotics

I had a really bad UTI a few weeks ago and I’m currently 16 weeks pregnant. The Urgent Care doctor I saw gave me Cephalexin (substituted for Keflex) and said it was safe for me to take. I was about 13 weeks when I started the medicine. I saw my OB and she said she was going to switch me to Nitrofurantoin Mono (substituted for Macrobid) because the Cephalexin wasn’t safe to take. I just finished the Nitrofurantoin a few days ago and noticed UTI symptoms coming back... I still have some pills from the other medication and was wondering if anyone else took them while pregnant?? One doctor said it was safe to take and another days differently soooo I don’t know if I should take them or not