ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 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
61 active users
1749 visitors today
1625 pages today
how is this done?
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

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

ASP.NET Blog
ASPRSS
ShawThing

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:
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)

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

Selling products online - read how James does it now



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...