Can I use PHP to redirect to a file if a server is unreachable? -


i host own server @ home use 000webhost means take domain , point server php script (my isp blocks port 80 "safety") wondering if take php script , have ping web server , if it's down redirect website/file letting few users know it's down. if php can't suggest?

use curl if want ping site, redirect.

function checksite($url, $timeout = 80) {           $curl = curl_init($url);           curl_setopt($curl, curlopt_timeout, $timeout);           curl_setopt($curl, curlopt_connecttimeout, $timeout);           curl_setopt($curl, curlopt_returntransfer, true);            $data = curl_exec($curl);           $response = curl_getinfo($curl, curlinfo_http_code);           curl_close($curl);        /**      * check if error ranges between 200 , 300      */     return ($response >= 200 && $response < 300) ? true : false; }  //check site if (checksite("http://yourdomain.com")) {     //your redirect here } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -