Code used to determine the redirection of a search engine

Source: Internet
Author: User
Determine the code for jump from the search engine. ask the hero to write a search engine to determine the code for jump.
If it is Baidu, jump to http://aaaa.com
Input directly without jump
I wrote the code before, but I don't know where to put the code.
For example

$ RUrl = $ _ SERVER ['http _ referer'];
If (! Empty ($ RUrl )){
$ UArray = parse_url ($ RUrl );
$ UHost = $ UArray ['host'];
Switch ($ UHost ){
Case 'www .baidu.com ':
Header ("Location: http://aaa.com ");
Break;
Case 'www .google.com ':
Header ("Location: http://bbb.com ");
Break;
Case 'www .sogou.com ':
Header ("Location: http://ccc.com ");
Break;
Default:
Echo $ UHost;
Break;
}
}
Echo 'direct? Inbound ';
--------------------------------------------------------------------------------

And below
Chapter content abstract:
PHP judges the redirection code of the search engine :? Php $ flag = false; $ tmp = $ _ SERVER ['http _ USER_AGENT ']; if (strpos ($ tmp, 'googlebot ')! = False) {$ flag = true;} else if (strpos ($ tmp, 'baidider Ider ') 0) {$ flag = true;} else if (strpos ($ tmp, 'Yahoo! Slurp ')! =
PHP judges the redirection code of the search engine:

$ Flag = false;
$ Tmp = $ _ SERVER ['http _ USER_AGENT '];
If (strpos ($ tmp, 'googlebot ')! = False ){
$ Flag = true;
} Else if (strpos ($ tmp, 'baidider Ider ')> 0 ){
$ Flag = true;
} Else if (strpos ($ tmp, 'Yahoo! Slurp ')! = False ){
$ Flag = 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, 'sogou 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 ){
$ Flag = true;
}
If ($ flag = false ){
// Header ("Location: http://www.hake.cc". $ _ SERVER ['request _ URI ']);
Require_once ("cd.htm ");
// Automatically go to the page corresponding to the http://www.hake.cc
// $ _ SERVER ['request _ URI '] indicates the path after the domain name
// Or change to header ("Location: http://www.hake.cc/abc/d.php ");
Exit ();
}
Else
{
Require_once ("news1.htm ");
}
?>



--------------------------------------------------------------------------------

JS judges the code for redirect from a search engine:

Var regexp = //. (sogou | soso | baidu | google | youdao | yahoo | bing | 118114 | biso | gougou | ifeng | ivc | sooule | niuhu | biso )(/. [a-z0-9/-] +) {} // ig;
Var where = document. referrer;
If (regexp. test (where ))
{
Window. location. href = 'http: hake. cc'
}


--------------------------------------------------------------------------------


Reply to discussion (solution)

Above you

$ RUrl = $ _ SERVER ['http _ referer'];
If (! Empty ($ RUrl )){
$ UArray = parse_url ($ RUrl );
$ UHost = $ UArray ['host'];
Switch ($ UHost ){
Case 'www .baidu.com ':
Header ("Location: http://aaa.com ");
Break;
Case 'www .google.com ':
Header ("Location: http://bbb.com ");
Break;
Case 'www .sogou.com ':
Header ("Location: http://ccc.com ");
Break;
Default:
Echo $ UHost;
Break;
}
}
Echo 'direct? Inbound ';

Can it be used? But I don't know where to put the code? Put it on the page you want to produce results

I have put the above

$ RUrl = $ _ SERVER ['http _ referer'];
If (! Empty ($ RUrl )){
$ UArray = parse_url ($ RUrl );
$ UHost = $ UArray ['host'];
Switch ($ UHost ){
Case 'www .baidu.com ':
Header ("locatati ......

If the spider function returns the name of the search engine
If (spider () = 'baidider Ider ') header ('loction: http://aaaa.com ');

   
Copy it to the host.


Use php to record the path of the search engine and keywords entered by the user's search
Http://3aj.cn/php/23.html

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.