OK, I wanna do it. How?It's easy as ABC with ASP. Have a look at the source below, wich appears in my Header function. (You can get the full source code by clicking on the icon at the end of the article) var sBrowser = "" + Request.ServerVariables ( 'HTTP_USER_AGENT' ); if ( -1 == sBrowser.indexOf ( 'Mozilla' ) && -1 == sBrowser.indexOf ( 'Opera' ) ) { // an unknown browser - probably a spider Out ( '<meta name="Keywords" content="Important phrase or keyword, another one">' ); Out ( '<meta name="Description" content="A full description of your site goes here.">' ); } else { // a browser - show some junk to make them think we're idiots Out ( '<meta name="Keywords" content="some throwaway words">' ); Out ( '<meta name="Description" content="A short description">' ); } |
Not too complicated, eh? The first line grabs the name of the browser, or at least what name it tells everyone. If you're interested, your browser calls itself: Mozilla/5.0 (compatible; archive.org_bot +http://www.archive.org) Looking through the venerable Browscap.ini you'll see that every IE and every Netscape version since 1.0 called themselves Mozilla! The only "popular" browser that doesn't is Opera, so on the second line I test for both strings. If either are present I output some junk META tags just so the visitor's suspicions aren't aroused. This is key, since there is an easy way to bypass this USER_AGENT check (if you know how). Of course, the spiders User Agent ID's aren't as well publicized, so if you know of any that call themselves Mozilla or Opera please let me know, and I'll make the test more sophisticated. Update: "CoolMB webmaster from York" also left a very useful review on Aspin.com about this article. As he correctly points out you can go further with this by serving up different META tags for specific search engines. Something for you to complete as homework perhaps? Thanks for the help with this article Beezle and CoolMB. |