Hotlink hijack


Written on 12. November 2008 – 15:39 | by seo23

So you get annoyed because too many people hotlink your images? Well here is a little solution. We just hijack those requests to display advertisement for our own page whenever someone requests your images from a remote page. We do this using .htaccess! ust put the following code into your .htaccess file (like we did in the redirects post). If you dont have one then just create it in your www directory and put the following lines in it:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ REPLACEMENT.jpg [R,NC]

Obviously you have to change the values first to reflect your website. Put up the image that you want to display for hotlinkers – in this case i named it REPLACEMENT.jpg but you can name it anything you want. Here you go, now noone is able to hotlink your precious images anymore!

Tags: , , , , ,



Post a Comment