Handle error redirect correctly