TacoFiesta
TacoFiesta

Reputation: 43

Block IP from Image Hotlinking htaccess

There is this IP '192.241.234.14'. The neighborhood has about 1200 sites that are hotlinking images from me.

I don't want to block every site but ours because I do rely on google image search quite a bit... along with others.

I have tried this

RewriteCond %{HTTP_REFERER} ^http://(.+\.)?192\.241\.234\.14 [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myabccoolpix\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/xxxxxxx.jpg [L]

Order Deny,Allow
Deny from 192.241.234.14

But the only way I can stop it successfully is to block each domain. Is there a better way?

Upvotes: 0

Views: 256

Answers (1)

TacoFiesta
TacoFiesta

Reputation: 43

I didn't want to do it like this. Blocks hotlinking for everyone

# allow blank referrer requests
RewriteCond %{HTTP_REFERER}     !^$

# allow all requests from your domain
RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?domain1\.   [NC]
RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?domain2\.   [NC]
RewriteCond %{HTTP_REFERER}     !^https?://11\.22\.333\.44(.*)$  [NC]

# search engine access
# include or remove search engines feed readers and other sites
RewriteCond %{HTTP_REFERER}     !search\?q=cache            [NC]
RewriteCond %{HTTP_REFERER}     !google\.                   [NC]
RewriteCond %{HTTP_REFERER}     !yahoo\.                    [NC]
RewriteCond %{HTTP_REFERER}     !bing\.                     [NC]
RewriteCond %{HTTP_REFERER}     !duckduckgo\.               [NC]
RewriteCond %{HTTP_REFERER}     !dogpile\.                  [NC]
RewriteCond %{HTTP_USER_AGENT}  !msnbot                     [NC]
RewriteCond %{HTTP_USER_AGENT}  !bing                       [NC]
RewriteCond %{HTTP_USER_AGENT}  !google                     [NC]
RewriteCond %{HTTP_USER_AGENT}  !ask                        [NC]
RewriteCond %{HTTP_USER_AGENT}  !yahoo                      [NC]
RewriteCond %{HTTP_USER_AGENT}  !slurp                      [NC]
RewriteCond %{HTTP_USER_AGENT}  !facebookexternalhit        [NC]
RewriteCond %{HTTP_USER_AGENT}  !yoast                      [NC]
RewriteCond %{HTTP_REFERER}     !yoast                      [NC]
RewriteCond %{HTTP_REFERER}     !bing                       [NC]
RewriteCond %{HTTP_REFERER}     !live                       [NC]
RewriteCond %{HTTP_REFERER}     !google                     [NC]
RewriteCond %{HTTP_REFERER}     !gstatic                    [NC]
RewriteCond %{HTTP_REFERER}     !yahoo                      [NC]
RewriteCond %{HTTP_REFERER}     !pinterest                  [NC]

RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/xxxxx.jpg [L]

Upvotes: 0

Related Questions