Jump to content

Archived

This topic is now archived and is closed to further replies.

buzzme

PHP - Guru needed !Redirect page on remote web host when local server is offline

Recommended Posts

I hope some one can help . I have my web site hosted on powweb and I want a user to be redirected when they access my local image server through a link on my web site to another page on my web site when my local image server is offline . I trust this makes sense and all replies welcome .

I have tried the following script but when my local server is offline it fails to redirect to a page on my website which lets the user know the server is offline .

<?php
if (! $sock = @fsockopen('localserver', 80, $num, $error, 2))
header("location: http://some_local_server/fif=cat.fpx&init=0.0,0.0,1.0,1.0&rect=0.46875,0.59 375,0.53125,0.65625&wid=300&hei=300&lng=en_US&enab lePastMaxZoom=OFF&page=simple/simple2.htm&obj=uv,1.0&cmd=reset");
else {
fclose($sock);
header("location: http://www.website_hosted_on_powweb.com/local_image_server_offline_message.html");
}
?>

P.S. It redirects to the first header okay .

Share this post


Link to post
Share on other sites
Thanks for the reply but I am already using one through www.no-ip.com . I am using their free service atm but do not see a redirect function when the server is unreachable . Does anyone know a free dns service that provides this ???? Or does anyone have a work around using curl or fsockopen ????

Share this post


Link to post
Share on other sites
run a cron job every 5 minutes or so that checks if your server is up or down. Have the script change a link in the database depending on if it's up or not, this is the link you will display.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.