Blocking Content by Referer
Friday, October 10. 2008
As I already wrote I am tired of people that use my images on their sites and consuming my bandwidth. Don't get me wrong. I always appreciate links to my site and I am pleased if you find something useful. What I don't like however is that someone refers to high resolution images as background images for his site that are meant as desktop wallpapers.
A colleague gave me the hint to block this sites by the referer through .htaccess files in the respective directories. And this works great for me:
RewriteEngine on
RewriteCond %{HTTP_REFERER} .taringa\.net [NC]
RewriteCond %{HTTP_REFERER} .myspace\.com [NC]
RewriteCond %{HTTP_REFERER} .blogger\.com [NC]
RewriteCond %{HTTP_REFERER} .blogspot\.com [NC]
RewriteRule .* - [F]
Essentially that blocks embedding content from my site into theirs. The Apache web server needs to have support for .htaccess files as well as the module mod_rewrite, but most servers have this by default. So this should not be a big problem.
The first lines makes sure that the rewrite engine is activated. The next four lines are blocking the most annoying sites. Note that the site is specified as regular expression. Therefore the dot before the TLD must be escaped by a preceeding backslash. [NC] tells the rule to ignore captialization. The last line finally will return an Access Denied error to those sites.
Trackbacks
Trackback specific URI for this entry



Comments
I recently had someone using a picture of my blog for an ebay auction. I replaced it with a banner to my site
I am good. My diploma thesis is turned in and my flight to Oslo (to my gf and to job search) is going next friday =)