Birdmansplace Posted January 19, 2009 Share Posted January 19, 2009 i am wounder if its possible to have a redirect to another page if the first one times out or isn't there. so say you go to www.yoursite.com/index.php and for some reason it doesn't load or isnt there it would take you to /index1.php? If that makes any sence. I am running a web site off my home connection and theres a few pages that some info i can't see cause of being hosted on another computer on my network and would like to see how the page looks and so on to the "world". My index page loads an iframe from another computer on my network so to the world i have to open another port so... and the only other way to do this from my knowledge is to make a second page the does everything localhost. Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/ Share on other sites More sharing options...
MadTechie Posted January 19, 2009 Share Posted January 19, 2009 Try this <?php $url = "http://www.doesnexist.com"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $output = curl_exec($ch); $info = curl_getinfo($ch); if ($output === false || $info['http_code'] != 200) { header("Location: index.php"); }else{ header("Location: $url"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-740313 Share on other sites More sharing options...
Birdmansplace Posted January 19, 2009 Author Share Posted January 19, 2009 fail cause of line 3 Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-740340 Share on other sites More sharing options...
MadTechie Posted January 19, 2009 Share Posted January 19, 2009 you need to enable CURL, create a php info page <?php phpinfo(); ?> open it and search for curl.. if you don't see it then enable it and restart apache to enable curl open php.ini find ;extension=php_curl.dll remove the ; so extension=php_curl.dll save restart apache Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-740369 Share on other sites More sharing options...
tqla Posted January 19, 2009 Share Posted January 19, 2009 If you have access to the server and CPanel, you can also do this at server level using Errors pages. Use Error page 404. Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-740598 Share on other sites More sharing options...
Birdmansplace Posted January 20, 2009 Author Share Posted January 20, 2009 <?php $url = "http://THIS IS WHERE I BUT LINK I WANT TO LOAD?"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $output = curl_exec($ch); $info = curl_getinfo($ch); if ($output === false || $info['http_code'] != 200) { header("Location: AND IF NOT FOUND PUT REDIRECT HERE?"); }else{ header("Location: $url"); } ?> i am kinda lost, this is what i am doing <iframe id="ListFrame" style="width:78%; height:250px; border:1px" src=" <?php $url = "http://http://www.webname.com:100/stats/server.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $output = curl_exec($ch); $info = curl_getinfo($ch); if ($output === false || $info['http_code'] != 200) { header("Location: http://192.168.x.xx/stats/server.php"); }else{ header("Location: $url"); } ?>"> </iframe> Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-740978 Share on other sites More sharing options...
MadTechie Posted January 20, 2009 Share Posted January 20, 2009 You can't have anything before a header.. so try this create a file called portal.php <?php $url = "http://http://www.webname.com:100/stats/server.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $output = curl_exec($ch); $info = curl_getinfo($ch); if ($output === false || $info['http_code'] != 200) { header("Location: http://192.168.x.xx/stats/server.php"); }else{ header("Location: $url"); } ?> then use that in the ifame <iframe id="ListFrame" style="width:78%; height:250px; border:1px" src="portal.php"> </iframe> that should work Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-741058 Share on other sites More sharing options...
Birdmansplace Posted January 21, 2009 Author Share Posted January 21, 2009 thanks. didn't know i have to make it in its own file. it works! Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-742047 Share on other sites More sharing options...
Birdmansplace Posted January 27, 2009 Author Share Posted January 27, 2009 Well it does work but it doesn't to the out side. so i just set it back to the way it was and test it another time Quote Link to comment https://forums.phpfreaks.com/topic/141420-solved-just-woundering/#findComment-747423 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.