Correct way is to use mod_rewrite to check the referrer and redirect to your site's main page if the referrer is not your site. The guide for Apache 2 is here:
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
I don't think mod_rewrite is part of the default build though.