Home  >  Article  >  Backend Development  >  PHP page jump implementation program code_PHP tutorial

PHP page jump implementation program code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:14:21725browse

Below we have summarized several methods of page jump in PHP. To achieve jump in PHP, you need to use the header function. Now I will introduce one by one for friends who need it to refer to.

The simplest way is to use php header

The code is:

The code is as follows
 代码如下 复制代码

header("Location:http://www.bKjia.c0m/");
?>

或者:

Copy code

header("Location:http://www.bKjia.c0m/");
?>

 代码如下 复制代码

$url=$_GET["url"];
header("Location:".$url);
?>

or:

 代码如下 复制代码

$url=""];
header("HTTP/1.1 301 Moved Permanently");
header ("Location:$url");
?>


Get the value through get or post and then jump

Sometimes you can see http://www.xxx.com/url.php?url=http://www.baidu.com, and then jump to Baidu.
How to implement this url jump using php?
It can be achieved with just a few simple lines of code.

The code is as follows Copy code
$url=$_GET["url"];

header("Location:".$url);

?> PHP 301 redirection implementation code
The code is as follows Copy code
$url=""]; header("HTTP/1.1 301 Moved Permanently"); header ("Location:$url");

?>
See status code in ff It’s easy. If you want to test, just use the curl software to check. #curl -I HTTP/1.0 301 Moved Permanently Date: Tue, 06 May 2008 06:27:39 GMT Server: apache Location: If you see the above HTTP/1.0 301 Moved Permanently http://www.bkjia.com/PHPjc/629022.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629022.htmlTechArticle Below we summarize several methods of page jump in php. To achieve jump in php, you need to use The header function, I will introduce it one by one below, friends in need can refer to it. The simplest...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn