Fixed redirect loop issue