Solving infinite redirect when code doenst exist