Talk:Preventing hotlinking

From DreamHost
Revision as of 18:09, 4 October 2010 by Rehevkor5 (Talk | contribs) (X-Frame-Options)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

FYI, if interested: Explanation of difficulties contributing to this and a related article.

Regular expressions

A subsection probably needs to be added that includes examples of regular expressions that match various domain names. Take the following two expressions from the article for example:


Those two rules only match

A different expression needs to be used if one intends to match any subdomains, for example:


Would match the following:

-- Atropos 23:20, 14 May 2006 (PDT)

My understanding of regular expressions little better than that of a stick of celery, so I'd be delighted to see you add the enhancements you suggest. An example-based article on regex would also be welcome! -- Scjessey 04:28, 15 May 2006 (PDT)

Replacing images

I was looking at the example for replacing images and thought about how it still costs bandwidth, is it possible to do something like this to prevent the loss of bandwidth?

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|png)$ [L]

--Einsidler 00:52, 24 Jun 2006 (PDT)

Replacing an image with another

I was amazed recently when I checked the logs of the site. The sheer number of sites that react abnormally to the 302 error generated when redirecting hot-linking sites to a 'theft'-image is staggering. Even Google Images (at least retries those accesses hundreds of times.

Also, the number of page accesses to your site will probably increase by a large number when you redirect in this way (though it is tempting to do so!) I estimate that the bandwidth occupied by image-substitution is actually larger (even when the replaced image is much smaller).

It's just better (though boring) to use the rejection trick (first examples).


Something about the new X-Frame-Options might be good here.

<IfModule mod_headers.c>
Header set X-Frame-Options "DENY"