CoverYourASP --> Hiding your META tags --> Part 2

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
48 active users
2370 visitors today
2046 pages today
(only part of today)
Tools I use

CoverYourASP
Copyright © 1999-2016 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

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.

Featured sponsor
My favorite resources


See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?