PHP header () function jump
PHP header () function is very powerful, which in the URL page Jump also called simple, using header () to jump directly to the specified URL page, then the page Jump is a 302 redirect:
$url = "http://www.goocode.net/";
header( "Location: $url" );
We may encounter special jump, such as website correcting a page address to do 301 redirection, of course you can be realized through the web configuration rewrite, but now I want to tell you, you can use the PHP header () function to do 301 jumps, the code as follows:
$url = "http://www.goocode.net/";
//301 redirect
if($_GET['t']=='301') header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: $url" );
Set meta to jump/redirect
HTML meta information can be set to jump directly, you can set the delay time URL jump and jump, often used, such as pay over tell users pay for success and jump to the order page, the code is very simple, in the to add a sentence:
<meta http-equiv="refresh" content="5;url=http://www.goocode.net">
It will redirect to http://www.goocode.net after 5 seconds.
javascript jump
javascript jump is also very simple, direct words:
<script>
window.location.href="http://www.goocode.net";
</script>
Note, the code above directly after the jump, in the target page address is not available antecedents (referer, also called source), in the actual project, meet customer requirements to jump to bring Road (i.e. target Webpage can get to the page where the jump to), this time, we can simulate a click javascript, and then jump to meet customer demand.
<script>
//With referer
var aa = document.createElement("a");
aa.setAttribute("href","http://www.goocode.net");
var bodys=document.getElementsByTagName("body")[0];
bodys.appendChild(aa);
aa.click();
</script>
Of course, in the actual development we can put the two ways to integrate into PHP, easy to apply in various jump demand.