Update index.php

Javascript to handle redirects