The best way to do this (platform independent of what browser/OS the user has) is to use a php redirect using the php header function.
Note 1: Php must be installed and running on your server, obviously.
Note 2: This only works if your content was in a php file to begin with. Putting this in an html/htm will not work unless your server is specifically set up to execute php scripts inside files with these extensions.
Note 3: The following code sends a 301 header to the browser, you can change the first line to whatever code you want to send(401, eg.)
Note 4: The ($_SERVER['HTTP_HOST'])) variable simply takes you to the root of your server (your home page usually).
Code:
<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header( 'Location: http://' . ($_SERVER['HTTP_HOST']));
?>
For those withougth the ability to run php:The javascript way of doing it...
Code:
<SCRIPT language="JavaScript">
<!--
function getgoing()
{
top.location="http://someplace.com";
}
if (top.frames.length==0)
{
alert("You will be redirected to our main page in 10 seconds!");
setTimeout('getgoing()',10000);
}
//-->
</SCRIPT>
No comments:
Post a Comment