I know by ".htaccess" one can prevent hotlinking of images , via this RewriteEngine On RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L] However ,my question is can i prevent hotlinking of images based on size concideration ? for eg not hotlink if images are above X kb . Bascially , i am running a simple image hosting script and if i blindly use the above code , even my thumbnails will be blocked from viewing on forums/websites , i do not want that, i just want the larger images to not be hotlinked. My host itself has a hotlink protection thing in CP , via which i can block hotlinking, however even the thumbnails dont show
I'm not sure that's possible but even if it is, you don't want your server to have to lookup a filesize every time an image is requested. A much easier way to achieve the same effect is to be consistent with image naming and apply the rewrite depending on that. In other words, if you create thumbnails and name them thumb_imagename.jpg, you can rewrite only requests for thumb_*. RewriteRule thumb_.*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]
oh yeah thats a good idea ..i didnt know about that.. but the code didnt work..needless to say .. im not really adept at all this currently the htaccess file has ... all hotlinking is blocked RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://mysite.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://mysite.com$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://mysite.com [R,NC] can u tell me what should i edit here? also .. my tnail's have the same filename as the images, (not any tnail_xyz.jpg) if there is someway i can allow a certain folder to be hotlinked images/thumbs/ is where my thumbnails lie , if access is allowed to this folder to be hotlinked it would do the trick .
yes i did it .... i added this RewriteCond %{REQUEST_URI} ^/images/thumbs/ RewriteRule ^.*$ - [L] ... any suggetion on this people?