Mihalism Technologies: Block hotlinking for large images ? - Mihalism Technologies

Jump to content

Welcome to the Mihalism Multi Host technical support forum. Mihalism Technologies does not have the funding or staffing required to provide direct support for everyone so we rely on our knowledgeable community to assist users. Therefore, answers to questions are not guaranteed. We do have the time to directly help a few users a day. If interested, you can find information regarding premium support here.

Need help with templates or creating custom designs? Read the Mihalism Template Engine Guide or ask for help in this forum.
  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Block hotlinking for large images ? Rate Topic: ***** 1 Votes

#1 User is offline   CasualNerd Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 14-May 09

Posted 14 May 2009 - 07:41 PM

Is it possible to block hotlinking of full size images but allow hotlinking of thumbnails ? I have tried the tricks I know with htaccess, but because all the images are in the same folder it's very difficult and I haven't worked out a solution yet.

Otherwise, is it possible to change the destination folder of the uploaded images so they end up in a different folder to the generated thumbnails, so I could use different htaccess files in each folder ?

I've asked this question elsewhere and it seems possible to do, but I can't get it to work.
0

#2 User is offline   Anthony Icon

  • Advanced Member
  • PipPipPip
  • Group: Helpers
  • Posts: 99
  • Joined: 30-April 09

Posted 14 May 2009 - 09:59 PM

One way to get it to work would be to have it block hotlinking, then explicitly allow hotlinking of images that contain _thumb in the name.

I've only worked sparingly with htaccess, so I may be wrong, but doesn't the statements execute in order? Meaning that the second one allowing the _thumb would override the first one.

Just a thought, haven't worked with .htaccess files in over a year, and only long enough to get my server working how I wanted it. So that could be horribly inefficient, or just plain incorrect. ~_~'
0

#3 User is offline   CasualNerd Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 14-May 09

Posted 14 May 2009 - 10:06 PM

Yep, that's as far as I got, I have the code if someone is good with htaccess, but everytime I try it, I get something wrong - it blocks all images, or none, or blocks images loading on my own site etc.
0

#4 User is offline   Anthony Icon

  • Advanced Member
  • PipPipPip
  • Group: Helpers
  • Posts: 99
  • Joined: 30-April 09

Posted 14 May 2009 - 10:10 PM

Well if the only problem is it's also blocking the images loading on your site, all you need is to explicitly allow any requests from your domain/referrer/internal IP address or whatever.
I didn't handle setting up most of my server, but I recall having to use htaccess to correct virtual hosting issues. Someone i know is rather good with them, if you want to post the code I can send it his way and see if he can fix it.
0

#5 User is offline   Josh D. Icon

  • Staff
  • PipPipPip
  • Group: Administrators
  • Posts: 474
  • Joined: 07-February 09

Posted 14 May 2009 - 11:20 PM

Try this:

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

#allow hotlinking for thumbnails
RewriteCond %{REQUEST_URI} !_thumb

#allowed website to hotlink  (don't forget to add your own site !!)
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com(/)?.*$ [NC] 

#display no-hotlink.jpg instead of the requested image
RewriteRule \.(jpg|jpeg|gif|png|bmp|ico)$ http://www.domain.com/no-hotlink.jpg [NC,R,L]


Replace domain.com with your domain name.

This post has been edited by Josh D.: 12 October 2009 - 08:26 PM

Do not PM me for support (message will be ignored), please use the support forum and one of the staff members will try to assist you.

Support Topic Guidelines
0

#6 User is offline   CasualNerd Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 14-May 09

Posted 15 May 2009 - 02:26 AM

Here's the code I was using when I was closest to getting it to work correctly:

CODE
<Files ~ "^.*\.(php|cgi|pl|php3|php4|php5|php6|phtml|shtml)">
    Order allow,deny
    Deny from all
</Files>

ErrorDocument 404 /css/images/error404.gif

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(www\.)?mydomain\.com [NC]
RewriteCond %{REQUEST_URI} !_thumb\.
RewriteRule \.(gif|jpg|jpeg|png)$ http://www.mydomain.com/css/images/errorhotlink.gif [R=301,L]


Unfortunately it was blocking large images on my own site as well ! Can anyone work out what I've done wrong ? (I did enter my actual domain name wink.gif )

This post has been edited by CasualNerd: 15 May 2009 - 02:27 AM

0

#7 User is offline   Anthony Icon

  • Advanced Member
  • PipPipPip
  • Group: Helpers
  • Posts: 99
  • Joined: 30-April 09

Posted 17 May 2009 - 12:00 AM

Did you try Josh D's method?
0

#8 User is offline   CasualNerd Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 14-May 09

Posted 17 May 2009 - 01:48 AM

QUOTE (Anthony @ May 16 2009, 11:00 PM) <{POST_SNAPBACK}>
Did you try Josh D's method?

I will, I just need to have some free time, last time I spent hours breaking and fixing things.
0

#9 User is offline   Mudassar Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 27-April 09

Posted 17 May 2009 - 05:36 AM

I tested it too. But not working too sad.gif

CODE
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

#allow hotlinking for thumbnails
RewriteCond %{REQUEST_URI} !_thumb

#allowed website to hotlink  (don't forget to add your own site !!)
RewriteCond %{HTTP_REFERER} !^http://(www\.)?4img.us(/)?.*$ [NC]

#display no-hotlink.jpg instead of the requested image
RewriteRule \.(jpg|jpeg|gif|png|bmp|ico)$ http://www.4img.us/no-hotlink.jpg [NC,R,L]


Please help.
0

#10 User is offline   Josh D. Icon

  • Staff
  • PipPipPip
  • Group: Administrators
  • Posts: 474
  • Joined: 07-February 09

Posted 17 May 2009 - 04:11 PM

Using the code I posted:

Posted Image

Image: http://www.hostmine....hvkq4k7bai1.jpg

This post has been edited by Josh D.: 21 April 2010 - 08:58 AM

Do not PM me for support (message will be ignored), please use the support forum and one of the staff members will try to assist you.

Support Topic Guidelines
0

#11 User is offline   CasualNerd Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 14-May 09

Posted 23 May 2009 - 06:48 AM

I have tried your method josh, with unusual results.

It blocks some full images but not others, I can't work out why. It also blocks full images from being displayed in the image host viewer page, even though I excepted the domain in the appropriate spot.

I've looked for errors but I can't work it out at all.
0

#12 User is offline   jojo Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 46
  • Joined: 01-May 09

Posted 01 June 2009 - 10:12 PM

i have tried josh method and it's not working either
yesterday my bandwidth goes from 3GB daily to suddenly +150GB daily angry.gif
some is hotlinking hundreds of images
0

#13 User is offline   jojo Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 46
  • Joined: 01-May 09

Posted 01 June 2009 - 11:48 PM

now it works I removed the cache and cookies rolleyes.gif
thank you Josh
0

#14 User is offline   CasualNerd Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 14-May 09

Posted 03 June 2009 - 01:15 AM

jojo, did you notice any of the problems I was having when it worked ?

I'm trying to work out what I've done wrong...
0

#15 User is offline   jojo Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 46
  • Joined: 01-May 09

Posted 03 June 2009 - 01:44 AM

QUOTE (CasualNerd @ Jun 3 2009, 01:15 AM) <{POST_SNAPBACK}>
jojo, did you notice any of the problems I was having when it worked ?

I'm trying to work out what I've done wrong...


no it works for me , first it wasn't work but when I delete cookies and cache and even change my ip and start with fresh browser it works like a charm
it doesn't block large images on your site , only on others sites
0

#16 User is offline   CasualNerd Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 14-May 09

Posted 04 June 2009 - 01:54 AM

Looks like I'll have to try again !
0

#17 User is offline   Anthony Icon

  • Advanced Member
  • PipPipPip
  • Group: Helpers
  • Posts: 99
  • Joined: 30-April 09

Posted 06 June 2009 - 09:15 PM

Maybe it's your server settings?
Not exactly sure what settings would do that though. >.<
0

#18 User is offline   Poison Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 17-April 09

Posted 10 June 2009 - 12:44 PM

I have the same problem for the last days... with the hotlinking.

HUGE amount of bandwidth wasted in the last 4 days : about 10-15 gb each day .. and I have only a few visitors a day.

I've tried Josh D solution of htacess mod, but even after this, in 10 hours, I've lost another 10 gb of bandwidth.

Questions:
1) How can I find what pictures are hotlinked?
2) How can I find what pictures are most visited ? (and consuming the most bandwidth) ?
0

#19 User is offline   jojo Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 46
  • Joined: 01-May 09

Posted 10 June 2009 - 12:46 PM

QUOTE (Poison @ Jun 10 2009, 12:44 PM) <{POST_SNAPBACK}>
I have the same problem for the last days... with the hotlinking.

HUGE amount of bandwidth wasted in the last 4 days : about 10-15 gb each day .. and I have only a few visitors a day.

I've tried Josh D solution of htacess mod, but even after this, in 10 hours, I've lost another 10 gb of bandwidth.

Questions:
1) How can I find what pictures are hotlinked?
2) How can I find what pictures are most visited ? (and consuming the most bandwidth) ?


see the server logs via cPanel or DirectAdmin
it will show you who send lot of hits , most probably a Chinese forums they usually send huge amount of visitors
0

#20 User is offline   Poison Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 17-April 09

Posted 10 June 2009 - 01:19 PM

QUOTE (jojo @ Jun 10 2009, 11:46 AM) <{POST_SNAPBACK}>
see the server logs via cPanel or DirectAdmin
it will show you who send lot of hits , most probably a Chinese forums they usually send huge amount of visitors


thanks mate.

yes, I see in cpanel, in awstats, at referrers, a LOT of hits (not visits) , from chinese forums. I have about 100 visitors a day, but over 100.000 hits from those forums daily,

Now, I will wait to see what wil happen after I modify the .htacess, and after I removed the direct link when uploading the pictures.
0

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic