PHP cloaking script

Sometimes you need to show another text to crawlers :)
This script check serfer User-Agent and if this UA is listed in variable $bot_lst - so, it’s bot…

  1. // List of bots:
  2. $bot_lst=array(
  3.              'google',
  4.              'msn',
  5.              'yahoo'
  6.            );
  7.  
  8. $is_bot=0;
  9. for($i=0; $i<sizeof($bot_lst); $i++)
  10.   if(strstr(strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']), strtolower($bot_lst[$i])))
  11.     $is_bot=1;
  12.  
  13. if($is_bot) echo 'Hello bot :)';
  14. else echo 'Hi user :]';
  15.  
  16. echo '<p>Your UserAgent: '.$HTTP_SERVER_VARS['HTTP_USER_AGENT'].'</p>';

Tags: , , , , , ,

Deny https from search engines indexing

Well, if you have such problem, let’s do the following:

  1. Create two files:
    1. robots.txt:
      User-agent: *
      Allow: /
    2. robots-https.txt:
      User-agent: *
      Disallow: /
  2. Now write in your .htaccess this:
    RewriteEngine on
    RewriteCond %{HTTPS} on
    RewriteRule ^robots\.txt$ robots-https.txt

That’s all :) Have a nice day.


Tags: , , , , , , ,