According to user-agent judge spider Code Black Hat Jump Code (JS version and PHP version) _javascript tips

Source: Internet
Author: User

Black Hat SEO means that there is a trick that everyone is using, in the server to judge the client browser user-agent and then do further operations,

There's always someone on the Internet using this code first a JS code to determine the site visitors routing if the search engine to the jump if it is direct access is not change this code is from the Internet to find a long time to thank the original author

<script language= "JavaScript" >
var pattern =/google/gi;
var pattern1=/yahoo/gi;
var keyvalue=escape (document.referrer);
if (Pattern.exec (keyvalue))
settimeout (
"windows.location= ' http://www.jb51.net '", 10*1000);
else if (pattern1.exec (keyvalue))
settimeout (
"window.location= ' http://www.jb51.net '", 10*1000);
</script>

If is the search engine's user-agent then 301 jumps The current network many cheats the friendship link is this practice (the code will put in the last)

Specifically there are a lot of ideas, jump, Joe Page and so today just put the code out of PHP code

The declaration code is Baidu down first write a simple
According to PHP's $_server[' http_user_agent '] to judge

<?php $tmp = $_server[' http_user_agent ']; if (Strpos ($tmp, ' Googlebot ')!== false) {    echo ' Google ';} else if (Strpos ($tmp, ' Baiduspider ') >0) {    echo ' Baidu ';} else if (Strpos ($tmp, ' Yahoo! Slurp ')!== false) {    echo ' Yahoo ';} else if (Strpos ($tmp, ' msnbot ')!== F alse) {    echo ' Msn ';} else if (Strpos ($tmp, ' Sosospider ')!== false) {    
echo ' Search ';  else if (Strpos ($tmp, ' Yodaobot ')!== false | | Strpos ($tmp, ' Outfoxbot ')!== false) {    echo ' Youdao ';} else if (Strpos ($tmp, ' Sogou web Spider ')!== false | | Strpos ($tmp, ' Sogou Orion spider ')!== false) {&NBSP;&NBSP;&NBSP;&N
Bsp;echo ' Sogou '; else if (Strpos ($tmp, ' Fast-webcrawler ')!== false) {    echo ' AllTheWeb ';} else if (Strpos ($tmp, ' G Aisbot ')!== false) {    echo ' gais ';} else if (Strpos ($tmp, ' Ia_archiver ')!== false) {  &
Nbsp; echo ' Alexa '; An else if (Strpos ($TMP, ' AltaVista ')!== false) {    echo ' AltaVista ';} else if (Strpos ($tmp, ' Lycos_spider ')!== false) {&
Nbsp;   echo ' Lycos '; else if (Strpos ($tmp, ' Inktomi slurp ')!== false) {    echo ' Inktomi ';}?>

The second paragraph with a jump

<?php $flag = false;
$tmp = $_server[' http_user_agent ']; if (Strpos ($tmp, ' Googlebot ')!== false) {     $flag = true;} else if (Strpos ($tmp, ' Baiduspider ') > 0 {     $flag = true;} else if (Strpos ($tmp, ' Yahoo! Slurp ')!== false) {     $fla
G = true; else if (Strpos ($tmp, ' MSNBot ')!== false) {     $flag = true;} else if (Strpos ($tmp, ' Sosospider ')!= = False) {     $flag = true;} else if (Strpos ($tmp, ' Yodaobot ')!== false | | Strpos ($tmp, ' Outfoxbot ') !== false) {     $flag = true;} else if (Strpos ($tmp, ' Sogou web Spider ')!== false | | Strpos ($TMP, ' so 
Gou Orion spider ')!== false) {     $flag = true;} else if (Strpos ($tmp, ' Fast-webcrawler ')!== false) {
     $flag = true; else if (Strpos ($tmp, ' Gaisbot ')!== false) {     $flag = true;} else if (Strpos ($tmp, ' ia_archiver ') !== false) {     $flag = true; else if (Strpos ($tmp, ' AltaVista ')!== false) {     $flag = true;} else if (Strpos ($tmp, ' Lycos_spider '!== false] {     $flag = true;} else if (Strpos ($tmp, ' Inktomi slurp ')!== false) {  &nbsp
;  $flag = true; } if ($flag = = False) {   header ("location:http://www.jb51.net". $_server[' Request_uri ');  
   //automatically go to http://www.jb51.net corresponding page     //$_server[' Request_uri ' as the path behind the domain name
    //or replaced with header ("location:http://www.jb51.net/abc/d.php");
   exit (); }?>

The third piece of code is judged after 301 jumps

if (Preg_match ("#" (google|slurp@inktomi|yahoo! Slurp|msnbot) #si ", $_server[' Http_user_agent")) {
header ("http/1.1-Moved Permanently");
Header ("location:http://www.saoyu.com/");
Exit;
}}

Black Hat means there is a risk, please use caution. If the recruit's friends feel looking for the back door.

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.