Jump to content

[SOLVED] just woundering


Birdmansplace

Recommended Posts

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.

Link to comment
Share on other sites

Try this  ;D

<?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");
}
?>

Link to comment
Share on other sites

<?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>

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.