Author Topic: In desperately need to stop Hotlinking  (Read 2606 times)

0 Members and 1 Guest are viewing this topic.

Offline placuti

  • Pre-Newbie
  • Posts: 4
    • View Profile
In desperately need to stop Hotlinking
« on: March 10, 2008, 03:22:09 PM »
Hello,
browsing this forum I can't find the solution for the major problem affecting my usage of 4images: how to prevent hotlinking.

I read various threads, however many were in German. I would like to read something explaining in English, step by step, a very basic solution to prevent other websites to link my images (and consume my bandwith).

I tried a remedy with the following .htaccess file:
Code: [Select]
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_REFERER} !^http://www.example.com/data/media/images_folder/ [NC,OR]
RewriteCond %{HTTP_REFERER} !^http://example.com/data/media/images_folder/ [NC]
RewriteRule [^/]+.(gif|jpg)$ - [NC,F,L]

I uploaded the .htaccess file via FTP in ASCII mode and placed in any of the images_folder (categories) including the photos.
However, this remedy prevents hotlinking but also prevents to view the image in 'details.php?image_id=...' . So it proves to be useless.  Am I putting .htaccess files in the wrong foders?

Could anybody suggest me a solution working with 4images1.7.4 release?
For me this is crucial in keeping to use 4image.
Thanks a lot.

Offline expo

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: In desperately need to stop Hotlinking
« Reply #1 on: March 20, 2008, 02:57:52 PM »
Code: [Select]
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

The first line of the above code begins the rewrite. The second line matches any requests from your own mysite.com url. The [NC] code means "No Case", meaning match the url regardless of being in upper or lower case letters. The third line means allow empty referrals. The last line matches any files ending with the extension jpeg, jpg, gif, bmp, or png. This is then replaced by the nohotlink.jpe file in your images directory. This JPEG image is using the extension jpe instead of jpg to prevent blocking your own replacement image.