echo Javascript window.location.href not working
Your browser treats the response as plaintext.
Prepend to you response a Content-Type: text/html\
n plus wrap your content inside an <html></html>
tag.
Try this way.
<?php
$yourURL="http://www.stackoverflow.com";
echo ("<script>location.href='$yourURL'</script>");
?>