Forum Moderators: phranque

Message Too Old, No Replies

How do I block a specific site in my htaccess file?

htaccess question

         

mailalan

7:57 pm on May 1, 2005 (gmt 0)

10+ Year Member



Below is my htaccess file. At the top I've listed the bad bots. At the bottom I've listed sites I want to allow to hotlink to images on my site.

My question is: How do I block a specific site from getting any image from my site including the "nolink" image. There is one specific site in my logs that is hitting the no hotlinking image (nolink.jpg) over and over and over. So I'd like to block them completely so they don't even get the nolink.jpg image. Let's say their url is 000.00.000.00. How can I block them completely?

Thanks for your help.
- Alan

SetEnvIfNoCase User-Agent "^EmailSiphon" bad_bot
SetEnvIfNoCase User-Agent "^EmailWolf" bad_bot
SetEnvIfNoCase User-Agent "^ExtractorPro" bad_bot
SetEnvIfNoCase User-Agent "^CherryPicker" bad_bot
SetEnvIfNoCase User-Agent "^NICErsPRO" bad_bot
SetEnvIfNoCase User-Agent "^Teleport" bad_bot
SetEnvIfNoCase User-Agent "^EmailCollector" bad_bot
SetEnvIfNoCase User-Agent "^WebWeasel" bad_bot
SetEnvIfNoCase User-Agent "^Web Mole" bad_bot
SetEnvIfNoCase User-Agent "^WebCollector" bad_bot
SetEnvIfNoCase User-Agent "^Email Magnet" bad_bot
SetEnvIfNoCase User-Agent "^eMailReaper" bad_bot
SetEnvIfNoCase User-Agent "^CopyRightCheck" bad_bot
SetEnvIfNoCase User-Agent "^dumbot" bad_bot
SetEnvIfNoCase User-Agent "^JoeDog" bad_bot
SetEnvIfNoCase User-Agent "^Missigua Locator 1.9" bad_bot
SetEnvIfNoCase User-Agent "^Ocelli" bad_bot
SetEnvIfNoCase User-Agent "^SiteSnagger" bad_bot
SetEnvIfNoCase User-Agent "^SurveyBot" bad_bot
SetEnvIfNoCase User-Agent "^WebBandit" bad_bot
SetEnvIfNoCase User-Agent "^Website Downloader http:" bad_bot
SetEnvIfNoCase User-Agent "^WebStripper" bad_bot
SetEnvIfNoCase User-Agent "^Titan" bad_bot
SetEnvIfNoCase User-Agent "^NetMechanic" bad_bot
SetEnvIfNoCase User-Agent "^Crescent" bad_bot
SetEnvIfNoCase User-Agent "^Wget" bad_bot
SetEnvIfNoCase User-Agent "^ProWebWalker" bad_bot
SetEnvIfNoCase User-Agent "^CheeseBot" bad_bot
SetEnvIfNoCase User-Agent "^TeleportPro" bad_bot
SetEnvIfNoCase User-Agent "^Harvest/1.5" bad_bot
SetEnvIfNoCase User-Agent "^CherryPickerSE/1.0" bad_bot
SetEnvIfNoCase User-Agent "^CherryPickerElite/1.0" bad_bot
SetEnvIfNoCase User-Agent "^WebBandit/3.50" bad_bot
SetEnvIfNoCase User-Agent "^Wget/1.6" bad_bot
SetEnvIfNoCase User-Agent "^Wget/1.5.3" bad_bot
SetEnvIfNoCase User-Agent "^LinkextractorPro" bad_bot
SetEnvIfNoCase User-Agent "^Flaming AttackBot" bad_bot
SetEnvIfNoCase User-Agent "^Bullseye" bad_bot
SetEnvIfNoCase User-Agent "^fastlwspider/1.0" bad_bot
SetEnvIfNoCase User-Agent "^SurfWalker" bad_bot
SetEnvIfNoCase User-Agent "^GetWebPage" bad_bot
SetEnvIfNoCase User-Agent "^lwp-trivial" bad_bot
SetEnvIfNoCase User-Agent "^URL_Spider_Pro" bad_bot
SetEnvIfNoCase User-Agent "^LNSpiderguy" bad_bot
SetEnvIfNoCase User-Agent "^Black Hole" bad_bot
SetEnvIfNoCase User-Agent "Indy Library" bad_bot
SetEnvIfNoCase User-Agent "Internet Explore 5.x" bad_bot
SetEnvIf Remote_Addr "195\.154\.174\.[0-9]+" bad_bot
SetEnvIf Remote_Addr "211\.101\.[45]\.[0-9]+" bad_bot

<Limit GET POST>
Order Allow,Deny
Allow from all
Deny from env=bad_bot
</Limit>

ErrorDocument 404 [example.com...]

RewriteEngine on
RewriteRule gallery/avatar\.gif$ - [R,L]
RewriteRule nolink.jpg$ - [R,L]
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?216.999.234.60(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?216.999.234.60.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.co.uk(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.co.uk.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.be(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.be.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.ca(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.ca.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.de(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.de.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.it(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.it.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.fr(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.fr.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.nl(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.nl.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.tw.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.tw.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.co.uk(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.co.uk.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.com.au(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.com.au.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.es.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.es.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi1.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi1.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi2.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi2.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi3.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi3.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi4.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi4.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi5.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi5.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi6.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi6.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi7.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi7.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi8.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi8.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi9.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?cgi9.ebay.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?previewitem.ebay.com(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?previewitem.ebay.com.*$ [NC]
RewriteRule \.(gif¦jpg)$ [example.com...] [R,L]

[edited by: jdMorgan at 1:45 am (utc) on May 2, 2005]
[edit reason] Obscured specifics per TOS. [/edit]

jd01

8:40 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Alan,

You should be able to use %{HTTP_HOST} as a condition to accomplish this.

RewriteCond %{HTTP_HOST}!^(www\.)?yoursite\.com [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?badguy\.com [NC]
RewriteRule . - [F]

You can sub an ip or partial ip for badguy.com, but keep in mind this will ban not just the picture, but the entire site... (I actually use something similar to keep from being 'framed', etc. but I don't ban I just rewrite to my domain.)

Hope this helps.

Justin

jdMorgan

9:51 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could save an awful lot of processing time by combining your ebay rules:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(nolink\.jpg¦gallery\.gif)$
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://216\.999\.234\.60
RewriteCond %{HTTP_REFERER} !^http://(www\.)?amotek\.co\.uk [NC]
#
RewriteCond %{HTTP_REFERER} !^http://(www\.)?ebay\.com [NC]
# cgi.ebay.com, cgi1.ebay.com,cgi1234.ebay.com, etc.
RewriteCond %{HTTP_REFERER} !^http://(www\.)?cgi[0-9]{0,3}\.ebay\.com [NC]
# cgi.ebay.co.uk, au, etc
RewriteCond %{HTTP_REFERER} !^http://(www\.)?cgi\.ebay\.co\.[a-z]{2} [NC]
# cgi.tw.ebay.com, cgi.es.ebay.com, etc.
RewriteCond %{HTTP_REFERER} !^http://(www\.)?cgi\.[a-z]{2}\.ebay\.com [NC]
# cgi.ebay.com.au, etc.
RewriteCond %{HTTP_REFERER} !^http://(www\.)?cgi\.ebay\.com\.[a-z]{2} [NC]
# reviewitem.ebay.com
RewriteCond %{HTTP_REFERER} !^http://(www\.)?previewitem\.ebay\.com [NC]
#
RewriteRule \.(gif¦jpg)$ http://www.example.com/Gallery/nolink.jpg [R,L]

Actually, they could be combined even further, but with a loss of clarity.

Replace all broken pipe "¦" characters above with solid pipe characters before use. Posting on this board modifies them.

[added]
Your ErrorDocument directive is malformed. It should read:


ErrorDocument 404 /error.html

If you'd like to know why, read the ErrorDocument documentation [httpd.apache.org], and try fetching a missing page with both variations of the directive using the server headers checker [webmasterworld.com]. If you leave it like it is, expect major problems with search engines.
[/added]

Jim