lets say that there is a site, but half the time you get the page cannot be displayed error.
i want to redirect to it but if it doesnt work, it redirects to another site. is this possible? and if it is can you tell me how?
lets say that there is a site, but half the time you get the page cannot be displayed error.
i want to redirect to it but if it doesnt work, it redirects to another site. is this possible? and if it is can you tell me how?
You mean redirect by like a .tk?Originally Posted by TarinC
You could use PHP, ( fsockopen() ), check if the file/site/whatever is up, if it is, just do header('Location: [URL]') to redirect to that site, if it's not, do header('Location: [URL]') to another site..
site1 - The page i will create
site2 - the page i want to redirect to
site3 - in case 2 is not up.
i want to create a page that will redirect to 2. when the site isnt up it will redirect to a 3rd site instead of the 2nd site.
is there a code to do that?
Last edited by TarinC; 10-25-2005 at 03:43 PM.
<?php
if(fopen("http://site2")){
echo "<script>window.location='http://site2';</script>";
} else {
echo "<script>window.location='http://site3';</script>";
}
?>
Last edited by Jim; 10-25-2005 at 04:24 PM.
http://www.j-fx.ws
Same thing I said. You should replace the javascript with just an HTTP header, and it will always work whether the vistor has JS disabled or not.Originally Posted by Jim
im sorry but im noob!
i dont get that.You should replace the javascript with just an HTTP header, and it will always work whether the vistor has JS disabled or not.
Take a look at http://php.net/header.
Header() is a function that is used to send raw HTTP headers to the browser/application viewing the page. In this case, the "Location: [URL]" header, which would instantly redirect the browser to the [URL], instead of having the wait for the page to completly load.
i did that and i get a error:Originally Posted by Jim
Warning: fopen() expects at least 2 parameters, 1 given
in "the file" on line 7
line 7 of the script would be: if(fopen("http://site2")){
Last edited by TarinC; 10-25-2005 at 09:12 PM.
you have to put whether you want to read or write or somthing i think im to lazy to look it up..