Fixed a bug when redirecting