invertigo Posted March 17, 2007 Share Posted March 17, 2007 Hello, Ive been looking for a nice Redirect if online script, but there i didnt manage to find one. I know its probably easy to create one, but i dont understand a single bit of PHP making this very hard for me . I found this code to redirect though: <?php header("Location: http://website.com/"); exit; ?> My question: Whats the best way to extend this into a "redirect if server is online" script. should i add a "if http://website.com is online, then redirect" like rule? and how could i do this?> Thank you very much, Invertigo. Quote Link to comment https://forums.phpfreaks.com/topic/43146-redirect-if-online/ Share on other sites More sharing options...
interpim Posted March 17, 2007 Share Posted March 17, 2007 $url="http://url.com"; if(empty(file_get_contents($url)){ page isn't open; } else{ header("Location: $url"); } I may be wrong on the function to use... some of the more experienced folks around here can probably straighten me out LOL Quote Link to comment https://forums.phpfreaks.com/topic/43146-redirect-if-online/#findComment-209535 Share on other sites More sharing options...
shaunrigby Posted March 17, 2007 Share Posted March 17, 2007 <? $result = shell_exec("ping webserver") if($result > 0){ //forward to online server } else { //forward to mirror } Quote Link to comment https://forums.phpfreaks.com/topic/43146-redirect-if-online/#findComment-209556 Share on other sites More sharing options...
invertigo Posted March 18, 2007 Author Share Posted March 18, 2007 Alright, Thank you very much. Im going to try this one . Quote Link to comment https://forums.phpfreaks.com/topic/43146-redirect-if-online/#findComment-209856 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.