Home > php教程 > php手册 > php URL跳转代码 减少外链

php URL跳转代码 减少外链

WBOY
Release: 2016-06-06 20:37:33
Original
897 people have browsed it

有时候我们需要添加外链但对于网站来说过多外链是不好的,那么我们可以通过跳转来实现。

URL跳转代码
1.代码:
$url=$_GET["url"];header("Location:"."http://".$url);?> 如保存为aaa.php,可以实现aaa.php?url=www.baidu.com跳转到百度的效果.
这个简单的调用了默认的$_GET变量.以及php默认跳转Location:

2.实例升级:增加if循环
代码:
代码如下:

$url=$_GET["url"];
if (strlen($url >=3)){
header("Location:"."http://".$url);
}
?>


URL转向页








Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template