Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Mod Rewrite Anti-Leech (A Better Version)


jdMorgan - 8:22 pm on Feb 6, 2005 (gmt 0)


Here's an example of how to add exclusions. This is copied from one of my sites. This code comes with no warranties, expressed or implied, and no support. You *will* probably have to modify it to suit your needs.

# BLOCK linking from outside our domain except Google, Yahoo, AllTheWeb, AltaVista, Gigablast,
# Comet Systems, SearchHippo, Wayback Machine, and freetranslation.com translators and caches,
# plus Netscape4 image loading.
RewriteCond %{HTTP_REFERER} .
# Your domain(s)
RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)?example\.com
# Your IP address(es)
RewriteCond %{HTTP_REFERER} !^http://192\.168\.0\.1$
# SE cache and transaltion service exclusions (substitute your own domain name for "example")
RewriteCond %{HTTP_REFERER} !^http://.*(search¦cache¦translate).+example\.com
RewriteCond %{HTTP_REFERER} !^http://images\.google\..+www\.example\.com
# Google image IPs
RewriteCond %{HTTP_REFERER} !^http://216\.239\.(3[2-9]¦[45][0-9]¦6[0-3])\..*example\.com
RewriteCond %{HTTP_REFERER} !^http://rds\.yahoo\.com/.+example\.com
RewriteCond %{HTTP_REFERER} !^http://aolsearch\.aol\.com/aol/search
RewriteCond %{HTTP_REFERER} !^http://babelfish\.altavista\.com/.*example\.com
RewriteCond %{HTTP_REFERER} !^http://.*gigablast\.com/
RewriteCond %{HTTP_REFERER} !^http://.*searchhippo\.com.*example\.com
RewriteCond %{HTTP_REFERER} !^http://web\.archive\.org/web/.+example\.com
RewriteCond %{HTTP_REFERER} !^http://fets.*\.freetranslation\.com.+example
RewriteCond %{HTTP_REFERER} !^http://client\.sidesearch\.lycos\.com
RewriteCond %{HTTP_REFERER} !^http://cc\.msnscache\.com/cache\.aspx
RewriteCond %{HTTP_REFERER} !^http://web.ask.com/redir.*example\.com
# Netscape 4
RewriteCond %{HTTP_REFERER} !^wy[cs]iwyg://[0-9]{1,2}/http://(www\.)?example\.com
# Synergetics translation
RewriteCond %{REMOTE_ADDR} [b] [/b]!^207\.228\.(19[2-9]¦2[01][0-9]¦22[0-3])\.
RewriteRule \.(jpg¦jpeg?¦gif¦js¦css)$ - [F]

You'll have to work out what you want and need by examining your raw server logs and testing.

[added] Make sure you replace the broken pipe "¦" characters with solid pipes before trying to use the code above. [/added]

Jim

[edited by: jdMorgan at 6:52 am (utc) on Feb. 7, 2005]


Thread source:: http://www.webmasterworld.com/apache/2783.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com