Fixed redirect loop bug in debug mode!