Forum Moderators: open

Message Too Old, No Replies

Google and .htaccess hotlinking protection.

         

matuloo

3:36 pm on Mar 14, 2003 (gmt 0)

10+ Year Member



Anyone knows if it might cause any trouble if I use .htaccess file to protect against hotlinking? Right now some ****s are posting urls directly to some of the pictures I have on my site, moreover they are posting it at some chat forums, and its costing me quite a lot in lost BW.

Anyone has any experience with this?

jdMorgan

3:58 pm on Mar 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



matuloo,

If you implement your hot-link blocking correctly, then you won't have problems. You should allow for (accept) blank referrers and referrers from Google and all other search engines and translation services that you want to be able to display your graphics. This is easily done with RewriteCond exclusions to the hotlinking RewriteRule.

Jim

TeofenGL

4:00 pm on Mar 14, 2003 (gmt 0)

10+ Year Member



look into configuring the .htaccess file(s) to check for HTTP_REFERRER - and reject if it matches a particular string
(but do not reject if is blank - see
[webmasterworld.com ]
}

this is a nice helpful link, as well:
[pc-netgroup.com ]

matuloo

5:59 pm on Mar 14, 2003 (gmt 0)

10+ Year Member



Thanks guys, gonna take a look at it.

jdMorgan

6:14 pm on Mar 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



matuloo,

Here's a full example [webmasterworld.com], including exceptions to allow well-know caches and translators.

HTH,

Jim

SebastianX

8:02 pm on Mar 14, 2003 (gmt 0)

10+ Year Member



Put the .htaccess file below in your image directory (ensure you haven't HTML pages and images in the same directory). It will redirect all accesses to files in the image directory from bookmarks and URLs not on your server and redirect them to your main index page, but allows the display of images on your pages.

RewriteEngine On

RewriteCond %{HTTP_REFERER}!^http://www.yourdomain.com:80 [NC]
RewriteCond %{HTTP_REFERER}!^http://yourdomain.com:80 [NC]
RewriteCond %{HTTP_REFERER}!^http://www.yourdomain.com [NC]
RewriteCond %{HTTP_REFERER}!^http://yourdomain.com [NC]

RewriteRule /* http://www.yourdomain.com/ [R,L]


(There is a space between "}" and "!^"!)

jdMorgan

8:14 pm on Mar 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



SebastianX,

You might want to take a look at post #3 in the link I cited. It offers a more compact and more comprehensive set of RewriteConds which you may find useful. Also, note that over-specifying your own domain (for example, by including a specific port number) may cause problems for you and for those who copy the code from this thread.

I would also recommend using an internal redirect, as opposed to the 302 temporary redirect you have specified.

HTH,
Jim

SebastianX

8:51 pm on Mar 14, 2003 (gmt 0)

10+ Year Member



Jim,
I figured matuloo operates an adult site, because I know his scenario (image hotlinkers with high traffic galleries and popular freeloader chatboards). Your solution (I didn't read it before posting, shame on me) is top notch. However, the simple 302 redirect I've suggested should be enough for adult stuff, where most webmasters link directly to the pics, so the redirect of hotlinked images to the homepage makes sense. I used the default port# because a few adult traffic sources add it in redirect/tracking scripts for some reasons and these legit users wouldn't see an image otherwise. Also
RewriteCond %{HTTP_REFERER}!^http://([a-z0-9-]+\.)*yourdomain.com/ [NC]
or
RewriteCond %{HTTP_REFERER}!^http://(www\.)?yourdomain\.com/ [NC]
would probably be faster than my sample above.
Thank you for pointing me to your post!