Topic: Anyway to block hotlinking unless it's a thumbnail?

Allowing hotlinking to any image will kill my bandwidth once hit tens of thousands of users.

So to help simmer things down I was wondering if there is a way to limit hotlinking but only to thumbnails or a certain bandwidth limit?

Maybe allow so many hits per day ect...

Something to limit those huge forum hotlinks that will blow servers up.

Thumbs up

Re: Anyway to block hotlinking unless it's a thumbnail?

Well... you can deny hotlink to embed full images and just allow the thumbs to be hotlinked.
But this must be done one layer above, I mean this has to be made using htaccess and server rules instead of some php handling.

So, deny the folder /images using htaccess (read this and this)

rodolfoberrios.com | PLEASE use Tech Support forums to ask for support!

Re: Anyway to block hotlinking unless it's a thumbnail?

Rodolfo wrote:

Well... you can deny hotlink to embed full images and just allow the thumbs to be hotlinked.
But this must be done one layer above, I mean this has to be made using htaccess and server rules instead of some php handling.

So, deny the folder /images using htaccess (read this and this)

Awesome I just added hotlink in the main directory, then turned off rewrite in the thumbnail directory.

Thanks!

Now, I need to tweak the image links page to only link to the thumbnail and to the page that I will have ads on.

Any ideas? I'm looking through files now to see if it's an easy tweak.

Also I have a redirect to a hotlink warning image but it won't show, it just says image:

http://myimghost.com/images/wWbjq.jpg

But the thumbnail shows fine.  smile

http://myimghost.com/images/thumbs/wWbjq.jpg

Thanks again.

Now if I click the redirect firefox says im in a loop:

The page isn't redirecting properly
     
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Here is the htaccess code:

ServerSignature Off
Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^api$ api.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

ErrorDocument 400 default
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 500 default

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?myimghost.com [NC]

RewriteRule \.(jpg|jpeg|png|gif)$ http://myimghost.com/hotlink.gif [NC,R,L]

Last edited by dwhs (2012-01-03 16:50:15)

Thumbs up

Re: Anyway to block hotlinking unless it's a thumbnail?

Sorry feel free to delete this mess.

I fixed it by adding htaccess in the image folder rather then the account root.

Now I need to just change the links.

Mission accomplished, I just removed the two remote link lines on the themes view.php page.


Dang it, one last issue.


Can I change it so the thumbnails link to the viewer page rather them the direct image?

Last edited by dwhs (2012-01-03 17:14:12)

Thumbs up

Re: Anyway to block hotlinking unless it's a thumbnail?

dwhs wrote:

Sorry feel free to delete this mess.

I fixed it by adding htaccess in the image folder rather then the account root.

Now I need to just change the links.

Mission accomplished, I just removed the two remote link lines on the themes view.php page.


Dang it, one last issue.


Can I change it so the thumbnails link to the viewer page rather them the direct image?

Piece of cake, I just changed the code:

function get_thumb_html($full=true) {
    if($full) {
        $href = get_img_url();

to

function get_thumb_html($full=true) {
    if($full) {
        $href = get_img_viewer();

In the template.functions.php page.

http://myimghost.com/images/thumbs/wWbjq.jpg

Last edited by dwhs (2012-01-03 17:47:46)

Thumbs up

Re: Anyway to block hotlinking unless it's a thumbnail?

it wasn't neccesary to edit the functions, you just need to use FALSE as the argument on the call of this functions on te view.php file roll

rodolfoberrios.com | PLEASE use Tech Support forums to ask for support!