Author Topic: Disabling Hotlinking  (Read 15137 times)

0 Members and 1 Guest are viewing this topic.

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Disabling Hotlinking
« on: April 24, 2003, 04:11:46 AM »
I have a need to disable hotlinking of photos.

Ive been to the following page:
http://www.htmlbasix.com/disablehotlinking.shtml

But no matter which one I try, 1 through 4, they all prevent images from being seen even from requests from my site.

So Im wondering whats going on and if there is another way of doing this?

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Disabling Hotlinking
« Reply #1 on: April 24, 2003, 06:27:30 AM »
Here's what I use:

Code: [Select]
# Disable image hot-linking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.*/.*$ [NC]
RewriteRule [^/]+.(gif|jpg|png)$ http://www.example.com/logo.gif [R,L]
I have this file placed in the 4images data directory.

But to be honest, there's no way anyone can help you if you don't post the .htaccess code you're trying to use.   :?
« Last Edit: March 09, 2005, 03:00:15 AM by Chris »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Disabling Hotlinking
« Reply #2 on: April 24, 2003, 04:12:25 PM »
Quote from: Chris
Code: [Select]
# Disable image hot-linking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.*/.*$ [NC]
RewriteRule [^/]+.(gif|jpg|png)$ http://www.example.com/logo.gif [R,L]
Just one draw back in this method, that u can not use media files (videa/audio), only pictures.
 :(
« Last Edit: March 09, 2005, 03:01:18 AM by Chris »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Disabling Hotlinking
« Reply #3 on: April 24, 2003, 04:50:46 PM »
I tried this, changing your domain with mine, but still produces red x'd images throughout my site.  Im wondering if it has something to do with the rewrite engine, does that need to be specially enabled on my server by chance, any clues?

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Disabling Hotlinking
« Reply #4 on: April 24, 2003, 11:40:31 PM »
Quote from: V@no
Quote from: Chris
Code: [Select]
# Disable image hot-linking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.*/.*$ [NC]
RewriteRule [^/]+.(gif|jpg|png)$ http://www.example.com/logo.gif [R,L]
Just one draw back in this method, that u can not use media files (videa/audio), only pictures.
 :(

That's not a problem.  Just add the file extension to the RewriteRule like this:
Code: [Select]
RewriteRule [^/]+.(gif|jpg|png|mpg|wmv|mp3)$ http://www.example.com/logo.gif [R,L]and so on...
« Last Edit: March 09, 2005, 03:01:38 AM by Chris »

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Disabling Hotlinking
« Reply #5 on: April 24, 2003, 11:46:33 PM »
Quote from: lakeside
I tried this, changing your domain with mine, but still produces red x'd images throughout my site.  Im wondering if it has something to do with the rewrite engine, does that need to be specially enabled on my server by chance, any clues?

Not usually.  mod_rewrite is typically installed on Apache web servers but not always.  The fact that you're seeing a red X implies that something is working.  I'm assuming your "logo.gif" found in the last line is actually a red X picture.  

You can check your server's setup by asking your host and/or by placing the following in a file named phpinfo.php
Code: [Select]
<?
phpinfo();
?>

Then open phpinfo.php from a web browser.  Look for the "apache" section, assuming your server runs Apache.  Under "Loaded Modules" you should find "mod_rewrite" listed.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Disabling Hotlinking
« Reply #6 on: April 25, 2003, 12:22:21 AM »
Quote from: Chris
That's not a problem.  Just add the file extension to the RewriteRule like this:
Code: [Select]
RewriteRule [^/]+.(gif|jpg|png|mpg|wmv|mp3)$ http://www.example.com/logo.gif [R,L]and so on...
No, this wont help, because as I understand, when embeded or external player send request for a media file to the server, it doesnt send the referer (or something like that). so it get deny.
« Last Edit: March 09, 2005, 03:01:50 AM by Chris »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Disabling Hotlinking
« Reply #7 on: April 25, 2003, 12:30:05 AM »
Okay, I did the phpinfo.php thing, and I found the following:
mod_rewrit
Yes, it didnt have an e on the end of rewrite.

Im wondering if it's something to do with my internet connection.  Im on a satellite connection, but I send requests via a dialup account, then receive it back via the satellite.  So Im not sure if somehow direcway is blocking my browser from sending a referrer.  Will have to try it with just the dialup account.

Offline bev4ho

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Disabling Hotlinking
« Reply #8 on: November 03, 2005, 09:54:39 AM »
I want to use the code by Chris in the second post.  I went to the data directory and found 5 files under it.  Which do I use or do I create a document? 

bev

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Disabling Hotlinking
« Reply #9 on: November 03, 2005, 02:41:34 PM »
.htaccess
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline bev4ho

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Disabling Hotlinking
« Reply #10 on: November 03, 2005, 08:06:51 PM »
I'm new to this.   I have a hard time figuring things out when I make a mistake, so forgive me, I'm trying to make sure I do this right.
   
Are you saying to create a htacess file there or place it where I see htacess after clicking on "public html" before going to the 4 images file?  I thought the instructions said add the code in the data directory.  Here is what is is in /4images/data directory. 
 Directory:  data
  File: database   
  File:  media 
  File:  thumbnails 
  File:  tmp_media
  File:  tmp_thumbnails
 Create New File

I tried stopping hot linking through cpanel's button a while back, which I assume changes htacess--and it stopped all posts to the website (I use FrontPage, if that makes a difference).  I'm thinking that putting this in the htaccess will stop hotlinking to photos all over the website, which is what I wanted, so that would be good.  I'm sorry to take your time with this.

thanks,

bev

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Disabling Hotlinking
« Reply #11 on: November 04, 2005, 12:32:09 AM »
Ok
1) make sure you got this right: its .htaccess not htaccess (see the dot?)
2) normaly .htaccess is "hidden" and u must activate "show hidden files" in your ftp client (the feature might be named different in your ftp client).
3) if you dont have .htaccess file in your /4images/data folder, then create one with notepad or any other plane text editor, add the code above and upload it to 4images/data folder.
4) we have a whole bunch of usefull information regarding image security and hotlinking, try search for topic "pic security"
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline bev4ho

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Disabling Hotlinking
« Reply #12 on: November 04, 2005, 04:20:39 AM »
I have been looking at your site as a guest for several days--and I have managed to do many of the simple mods, because of your excellent instructions.  The support you give for people like me who don't understand is what encouraged me to try those others and to ask about this one now.   

Thank you very much,

bev

Offline Jmello

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Disabling Hotlinking
« Reply #13 on: January 06, 2006, 01:33:24 AM »
Hi!
I used the disable Hot Linking option from my server and than the mp3's and wmv files were not playing!But I could see the image files.
When I disabled the "Disable hot linking" to mp3 and wmv it went back to normal...
But I still want to protect them  :(
Sorry if it was answered somewhere else, but I´ve been searching and did not find the answer yet :oops:
Thanks!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Disabling Hotlinking
« Reply #14 on: January 06, 2006, 01:48:08 AM »
Hi!
I used the disable Hot Linking option from my server and than the mp3's and wmv files were not playing!But I could see the image files.
When I disabled the "Disable hot linking" to mp3 and wmv it went back to normal...
But I still want to protect them :(
Sorry if it was answered somewhere else, but Iґve been searching and did not find the answer yet :oops:
Thanks!

yes, its a known issue with windows media player plugin in browsers...when it requests a media file from the server, it does not send information about the page its on (referrer page) - and your anti-hotlinking features is based on that. In Firefox it also does not send information about temporary cookies, so sessions get lost.
I've tryed do a little research on this issue, but could not find an answer how to resolve it...maybe you, knowing the reason, could be more lucky ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)