
Originally Posted by
William Malacarne
Can you just change the picture that is hot linked with one of a jpg notice that says "This Picture Was Unlawfully Stolen From Someone Else's Sight".
Ultimately that's what you usually do, though it’s done automatically for you by your webserver.
This can be done automatically because every time your browser requests something from a webserver, it tells the server who sent it and because you can mangle things on your webserver. If you went to a page by typing in say "http://birdphotographers.net" into your browser the referrer filed will be blank since nobody sent you. However, if you’re looking at an image in one of the critique threads here, when your browser went to load that image it tells the server that it was being sent by birdphotographers.net. In our case we take advantage of the referrer bit and the fact we can serve whatever we want not necessarily, what was requested to stop hot linking.
Potentially scary non-photography stuff follows:
The following applies to people using Apache web server (most hosting providers use this).
You need to create an file in the root directory for your website called “.htaccess”. In that file, you add commands similar to the following:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
The first line tells the web server that you want to be able to mangle URLs before it does anything else with them.
The second line tells the server not to mess with things when the browser is referred by your domain; though obviously you have to change “example\.com” to your actual domain (the ‘\’ before the ‘.’ is important).
The third line stops people from just typing the image's URL into their browser directly. This would stop someone posting the image’s URL and telling people to copy and paste it into their address bar. However, it also will break embedding images into an email if you were going to do something like Mr. Morris's BAA Bulletin. Therefore, you might not want to do this.
The final line tells the server what files to match by extension (the "*\.(jpe?g|gif|bmp|png)$” bit) and what to substitute ("/images/nohotline.jpg” bit). You’d need to change the last part to match where you put the image you want to serve up to hot linkers. What you serve in place of the real content is up to you though it must be an image file.
The result is when someone embeds your image in their webpage and someone visits the bad site, instead of seeing http://example.com/images/nicephotoofsomebirds.jpg they see the picture http://example.com/images/theiftisbad.jpg but you don’t have to do anything for each image and every image on your site is protected.
If you wanted to add an exception, say so you can post an image to BPN hosted on your sever, you'd add another line like the second one.
Code:
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?birdphotographers\.net/ [NC]