Correcting infinite redirection loop