PHP to determine the route of the search engine and then jump code

Source: Internet
Author: User
  1. /**
  2. * Determine the search engine to route the page
  3. * edit:bbs.it-home.org
  4. */
  5. $flag = false;
  6. $tmp = $_server[' http_user_agent ');
  7. if (Strpos ($tmp, ' Googlebot ')!== false) {
  8. $flag = true;
  9. } else if (Strpos ($tmp, ' Baiduspider ') >0) {
  10. $flag = true;
  11. } else if (Strpos ($tmp, ' Yahoo! slurp ')!== false) {
  12. $flag = true;
  13. } else if (Strpos ($tmp, ' MSNBot ')!== false) {
  14. $flag = true;
  15. } else if (Strpos ($tmp, ' Sosospider ')!== false) {
  16. $flag = true;
  17. } else if (Strpos ($tmp, ' Yodaobot ')!== false | | Strpos ($tmp, ' Outfoxbot ')!== false) {
  18. $flag = true;
  19. } else if (Strpos ($tmp, ' Sogou web Spider ')!== false | | Strpos ($tmp, ' Sogou Orion spider ')!== false) {
  20. $flag = true;
  21. } else if (Strpos ($tmp, ' Fast-webcrawler ')!== false) {
  22. $flag = true;
  23. } else if (Strpos ($tmp, ' Gaisbot ')!== false) {
  24. $flag = true;
  25. } else if (Strpos ($tmp, ' Ia_archiver ')!== false) {
  26. $flag = true;
  27. } else if (Strpos ($tmp, ' AltaVista ')!== false) {
  28. $flag = true;
  29. } else if (Strpos ($tmp, ' Lycos_spider ')!== false) {
  30. $flag = true;
  31. } else if (Strpos ($tmp, ' Inktomi slurp ')!== false) {
  32. $flag = true;
  33. }
  34. if ($flag = = False) {
  35. Header ("location:http://www.xxx.com". $_server[' Request_uri ');
  36. Require_once ("cd.htm");
  37. Automatically go to the http://www.xxx.com corresponding page
  38. $_server[' Request_uri ') is the path behind the domain name
  39. or header ("location:http://www.xxx.com/abc/a.php");
  40. Exit ();
  41. }
  42. Else
  43. {
  44. Require_once ("index.htm");
  45. }
  46. ?>
Copy Code
  • 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.