Prevent Hotlinking from Specific Sites Only
You want to prvent hotlinking.
But not ALL websites. Sometimes you don’t mind if someone hotlinks from a forum or a review about your product, etc. However there are those that you DO want to block.
You can use the code below and place it into your htaccess file.
I placed the code in the .htaccess file inside my images folder, to just protect that folder, and to keep things straight forward.
If you wish to send a differnt image to the offending website, change the last line to an image that is outside your domain, or in a folder a level above where your .htaccess file is located.
Example: If I placed the code in the .htaccess file inside http://example.com/images, then my “nohotlink.jpg” image should be located http://example.com/nohotlink.jpg (otherwise it will blocked by it’s own rule).
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?ebay\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?ebay\.ca/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?abc\.net/ [NC]
RewriteRule .*\.(jpg|gif|bmp|png)$ http://example.com/nohotlink.jpg [L]
8. August 2008 at 2:45 pm :
THANK YOU!
I’ve been trying all sorts of code from various sites and they all ended up making my links on other sites come up horribly wrong. Looking like I hotlinked from my own site TO my own site was especially embarassing.
This code worked. Thanks again.
8. October 2008 at 8:34 pm :
[...] public links >> hotlinking Prevent Hotlinking from Specific Sites Only Saved by kittymau on Tue 07-10-2008 How to prevent hotlinking to FLV files? (Flash Videos) Saved [...]