1. Use HTTP header information
That is, use the php header function. The HEADER function in PHP is used to send control commands that should have been specified by the HTTP protocol to the browser through the WEB server, such as declaring the type of returned information ("Context-type: xxx/xxx "), page attributes (" No cache "," Expire "), and so on.
Use the HTTP header to redirect PHP to another page as follows:
- <?Php
- $Url="Www.baidu.com";
- If (! Empty ($ url ))
- {
- Header ("HTTP/1.1 303 See Other"); // This statement can be left empty
- Header ("Location: $ url ");
- }
- ?>
Note that "Localtion:" is followed by a space.
2. Mark PHP redirection with HTML
The HTML Tag is the REFRESH tag of META, for example:
- <?php
- if (!empty($url))
- {
- echo "<META HTTP-EQUIV="Refresh" CONTENT="0;URL=$url">";
- }
- ?>
3. Use scripts to implement PHP redirection
Example:
- <?
- if (isset($url))
- {
- echo "<SCRIPT LANGUAGE="JavaScript">";
- echo "location.href='$url'";
- echo "</SCRIPT>";
- }
- ?>
Or
- <?php echo "<script>window.location ="$url";</script>";?>