i may be totally under-thinking this, but a really brief and crude thought...just bypass your normal routines, if it's a bot.
(I'm assuming, you probably want to do less work on them anyways.)...and just split it into two sections. Bots and Not-Bots.
if ($ENV{'HTTP_USER_AGENT'}=~/^googlebot\/2\.1|slurp|some_other_bot_na
+me$/){
#put any other routines you want to run on the request -> like logs, e
+tc here or just...
print "Location: "http:\/\/www\.example\.org\/$ENV{'PATH_INFO'}";
}
# And if not in your bot-list, do what you originally planned...
else{
your original script's body here
}
it probably be easier to use the whole googlebot\2.1 stuff in a $variable associated with some array - than putting too many | or statements into that regex... but i'm being lazy and non-thinking at the moment.
one word of caution before using something like this-> any and all $ENV variables need to be cleaned up; One needs to ensure that they have no evil characters in them. As a thought for the directories you have there:
$ENV{'PATH_INFO'}=~/^([a-zA-Z_0-9]+\/?)*$/
one can't rely on the $ENVironmental variables too much, but in this case, it probably would work.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.