• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Anyway to block hotlinking unless it's a thumbnail?

Status
Not open for further replies.

dwhs

myimghost.com
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.
 
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)
 
Rodolfo said:
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:

wWbjq.jpg


But the thumbnail shows fine. :)



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:

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]
 
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?
 
dwhs said:
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:

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

to

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

In the template.functions.php page.

 
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 :rolleyes:
 
Does this still work with version 2.2? I noticed that the large images and thumbs are in the same folder.
 
Does this still work with version 2.2? I noticed that the large images and thumbs are in the same folder.

It needs a little tweak in the rule:
Code:
RewriteRule \.th\.(jpg|jpeg|png|gif)$ http://myimghost.com/hotlink.gif [NC,R,L]
 
Doesn't work. Would it be because the thumbnails are in the same folder? Possible to specify a thumbnail folder?

Code:
$config['folder_thumbs'] = 'images/thumbs'; // Just for legacy concerns, this is actually not used anymore since 2.1
 
Nope, wrong rule. Im actually from my ipad my pc is installing the OS I will check it later.
 
I've test this rule and it seems to work...

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://demo.chevereto.com [NC]
RewriteCond %{REQUEST_URI} !^(.+)\.th\(jpg|jpeg|png|gif) [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://demo.chevereto.com/hotlink.gif [NC,R,L]
 
Not sure if I am doing this correctly but here is my .htaccess file which I uploaded to the images directory. After uploading an image, the image does not show on the view page.

Code:
ServerSignature Off
Options -Indexes -MultiViews
 
Options +FollowSymLinks
RewriteEngine On
 
# If you have problems with the rewrite rules, remove the "#" from the following RewriteBase line
# You will also have to change the path to reflect the path to your Chevereto installation
#RewriteBase /chevereto
 
RewriteRule ^api$ api.php [L]
RewriteRule ^admin/(.*) admin/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
 
ErrorDocument 400 default
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default
 
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://mywebsite.com [NC]
RewriteCond %{REQUEST_URI} !^(.+)\.th\(jpg|jpeg|png|gif) [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://mywebsite/hotlink.gif [NC,R,L]
 
I've test it and there was a error on the code, this is the correct rule:
Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://demo.chevereto.com [NC]
RewriteCond %{REQUEST_URI} !^(.+)\.th\.(jpg|jpeg|png|gif) [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://demo.chevereto.com/hotlink.gif [NC,R,L]
 
Status
Not open for further replies.
Back
Top