How do you deal with Hotlinking?

I found myself having images hotlinked from gaydemon.com, I’m sure its something that happens a lot. In this case a blog which DZinerbear found had hotlinked images both from him and me.

I’ve been looking around at solutions but there seems no safe way of disabling hotlinking. Most of them rely on htaccess which can also cause problems with legit requests such as search engines, caches etc.

Here are how some have done it with htaccess:

Underscrorebleach.net

A list Apart

How do you deal with hotlinks without possibly preventing legit requests?

Re: How do you deal with Hotlinking?

Personally i use selective hotlinking like you mentioned above (underscorebleach)

Re: How do you deal with Hotlinking?

You might talk to Ray at BetterCGI (Strongbox). I think he has something proprietary that he’s built into Strongbox that handles this in a sophisticated way, perhaps (if I am correct) you can either adapt Strongbox or get that code snippet.

Re: How do you deal with Hotlinking?

I take the approach of specifying the sites that are allowed to hotlink and serve a logo to everyone else…

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !(^http://www\.rawtop\.com|^http://vod\.rawtop\.com|^http://theater\.aebn\.net|^http://www\.wilywilly\.com|^http://feeds.feedburner.com/rawtop|^http://www.blogger.com/post-|^http://pipes.yahoo.com/pipes/|^http://www.google.com/reader/view/|mail.yahoo.com) [NC]
RewriteCond %{REQUEST_URI} !^/resources/(pics|mgc|shared)/ [NC]
RewriteRule \.(gif|jpe?g|png|swf|flv|m4v|wmv|mpe?g)$ /resources/rawtop-large.gif [L,NC]

That also allows certain directories to be hotlinked (say a logo for a forum signature).

The critique of that approach is people can’t link directly to the image. That’s OK in my book. I doubt that would ever happen in my case, and I’d rather they link to the page anyway…

Re: How do you deal with Hotlinking?

Isn’t there a modification for this where instead of getting the hot linked image they are taken to a webpage?

[QUOTE=rawTOP;21747]I take the approach of specifying the sites that are allowed to hotlink and serve a logo to everyone else…

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !(^http://www\.rawtop\.com|^http://vod\.rawtop\.com|^http://theater\.aebn\.net|^http://www\.wilywilly\.com|^http://feeds.feedburner.com/rawtop|^http://www.blogger.com/post-|^http://pipes.yahoo.com/pipes/|^http://www.google.com/reader/view/|mail.yahoo.com) [NC]
RewriteCond %{REQUEST_URI} !^/resources/(pics|mgc|shared)/ [NC]
RewriteRule \.(gif|jpe?g|png|swf|flv|m4v|wmv|mpe?g)$ /resources/rawtop-large.gif [L,NC]

That also allows certain directories to be hotlinked (say a logo for a forum signature).

The critique of that approach is people can’t link directly to the image. That’s OK in my book. I doubt that would ever happen in my case, and I’d rather they link to the page anyway…[/QUOTE]

Re: How do you deal with Hotlinking?

I will check with my webmaster. We do have something in place.

Re: How do you deal with Hotlinking?

The problem with that approach is that it won’t render if the browser is expecting an image. You can’t put an HTML document in an <img> tag… But you can put an image with rasterized text - though the proportions may be skewed dramatically when it’s rendered.

Re: How do you deal with Hotlinking?

There is:

http://underscorebleach.net/jotsheet/2004/11/stop-image-hotlinking-tutorial-htaccess-apache

Thats exactly what that guy does, he servers a shtml page instead.

But rawtop is right, in a normal case it wouldnt work. However that page gives you a way of doing it.

Re: How do you deal with Hotlinking?

I noticed you dont allow most of googles subdomains. Doesnt that mean you loose out on SEO traffic?

I get a considerable amount of traffic from Google Images, which is partly why I’m hesitating to do any htaccess that involves blocking images.

I dont think its a huge amount of bandwidth I loose anyway due to hotlinking, but had there been a fool proof way of doing it I wouldnt mind using it.

[quote=rawTOP;21747]I take the approach of specifying the sites that are allowed to hotlink and serve a logo to everyone else…

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !(^http://www\.rawtop\.com|^http://vod\.rawtop\.com|^http://theater\.aebn\.net|^http://www\.wilywilly\.com|^http://feeds.feedburner.com/rawtop|^http://www.blogger.com/post-|^http://pipes.yahoo.com/pipes/|^http://www.google.com/reader/view/|mail.yahoo.com) [NC]
RewriteCond %{REQUEST_URI} !^/resources/(pics|mgc|shared)/ [NC]
RewriteRule \.(gif|jpe?g|png|swf|flv|m4v|wmv|mpe?g)$ /resources/rawtop-large.gif [L,NC]

That also allows certain directories to be hotlinked (say a logo for a forum signature).

The critique of that approach is people can’t link directly to the image. That’s OK in my book. I doubt that would ever happen in my case, and I’d rather they link to the page anyway…[/quote]

Re: How do you deal with Hotlinking?

[QUOTE=gaydemon;21792]I noticed you dont allow most of googles subdomains. Doesnt that mean you loose out on SEO traffic?

I get a considerable amount of traffic from Google Images, which is partly why I’m hesitating to do any htaccess that involves blocking images.

I dont think its a huge amount of bandwidth I loose anyway due to hotlinking, but had there been a fool proof way of doing it I wouldnt mind using it.[/QUOTE]

It’s not an issue… Click here for an example

Let me explain why… Google Images sets a frameset. The small image they have in the top frame is one they create and is on their server, hence their thumbnails aren’t served off my server and don’t encounter hotlinking code.

Next, the large frame is the page on my server, and the images on that page have that page as their referrer - not the frameset. That means the images load just fine.

What some people do is to have frame breaking code to remove Google Images’ frameset, but that’s a bad idea because it breaks the back button and Google will drop you from Google Images if they see it.

The other thing to think about in regard to Google Images is that the traffic is actually FAR more than Google Analytics reports. GA is a bit retarded when it comes to frames and hits on pages that are in a frameset served by another domain do not get counted as hits. You can set target="_top" on your links, but then it will appear to be direct traffic since GA interprets initial referrers from the same domain as the page as direct traffic. The only way you ever actually see Google Images as a referrer in GA is if they click on one of the links GI provides in the top frame. Since most people don’t do that, most of GI traffic is not shown in GA…

The only thing I’m concerned about are people on Google Reader (like myself). I let the images load there, and if I had a handy list of other big RSS readers and their URLs I’d permission those as well.