Php url redirection Methods)

Source: Internet
Author: User

[Use the header () function]
The HTTP-related function type of PHP provides a header () function. First, it must be clear that the header () function must be placed at the beginning of the php program, and there cannot be another header () the function or setcookie () is called. If it contains webpage output, this statement must be placed before the <HEAD> </HEAD> mark.

Use the following statement:

<?
Header ("location: http://www.bibias.com ");
Exit;
?>

As long as this statement is executed, the web page will be automatically redirected to the http://www.bibias.com


[Use HTML to mark redirection]


<HTML>
<HEAD>
<?
If (isset ($ url ))
{
Echo "<META HTTP-EQUIV = \" refresh \ "CONTENT = \" 5; url = $ url \ "> ";
}
?>
</HEAD>
<BODY>
</BODY>
</HTML>


CONTENT = "5; url = $ url" indicates that after 5 seconds, the webpage will automatically turn to the address $ url.


[Implement redirection using js Scripts]


<Html>
<?
$ Url = "http://www.bibias.com ";
Echo "<script language = \" javascript \ "> ";
Echo "location. href = \" $ url \"";
Echo "</script> ";
?>
</Html>

I don't have much time to learn about it. I prefer to use javascript.
Author: Qingyi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.