You mean redirect by like a .tk?TarinC said: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?
Jim said:<?php
if(fopen("http://site2")){
echo "<script>window.location='http://site2';</script>";
} else {
echo "<script>window.location='http://site3';</script>";
}
?>
You should replace the javascript with just an HTTP header, and it will always work whether the vistor has JS disabled or not.
Jim said:<?php
if(fopen("http://site2")){
echo "<script>window.location='http://site2';</script>";
} else {
echo "<script>window.location='http://site3';</script>";
}
?>
<?php
header("Location: http://[color=red]www.blaa.com[/color]/");
?>
http://php.net/fopen said:Description
resource fopen ( string filename, string mode [, bool use_include_path [, resource zcontext]] )
fopen() binds a named resource, specified by filename, to a stream. If filename is of the form "scheme://...", it is assumed to be a URL and PHP will search for a protocol handler (also known as a wrapper) for that scheme. If no wrappers for that protocol are registered, PHP will emit a notice to help you track potential problems in your script and then continue as though filename specifies a regular file.
<?php
$site1 = "http://www.yahoo.com";
$site2 = "http://www.google.com";
$handle = @fopen($site1, "r");
if ($handle) {
fclose($handle);
header("Location: $site1"); // Redirecting to $site1
} else {
fclose($handle);
header("Location: $site2"); // Redirecting to $site2
}
?>
<?php
$site1 = "[url="http://tps.servecounterstrike.com:27016/ip.w"]http://tps.servecounterstrike.com:27016/ip.w[/url]";
$site2 = "[url="http://tps.x10hosting.com/tps/custom/html/offline.html"]http://tps.x10hosting.com/tps/custom/html/offline.html[/url]";
$handle = @fopen($site1, "r");
if ($handle) {
fclose($handle);
header("Location: $site1"); // Redirecting to $site1
} else {
fclose($handle);
header("Location: $site2"); // Redirecting to $site2
}
?>
<?php
$site1 = "http://www.yahoo.com";
$site2 = "http://www.google.com";
$handle = @fopen($site1, "r");
if ($handle) {
fclose($handle);
header("Location: $site1"); // Redirecting to $site1
} else {
fclose($handle);
header("Location: $site2"); // Redirecting to $site2
}
?>
<?php
$site1 = "http://www.yahoo.com";
$site2 = "http://www.google.com";
$handle = @fopen($site1, "r");
if ($handle) {
header("Location: $site1"); // Redirecting to $site1
fclose($handle);
} else {
header("Location: $site2"); // Redirecting to $site2
}
?>