refactor redirect.php