The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Correct way to use Hotlink protection

Discussion in 'General Discussion' started by YukFoo, Nov 16, 2002.

  1. YukFoo

    YukFoo Well-Known Member

    Joined:
    Sep 1, 2002
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    16
    What's the correct way to use hotlink protection. When we try and only protect downloadable files from being linked to (our own music files), it doesn't work. Sometimes our images don't even show up. These file extensions we are trying to protect are .mp3 and .m3u
     
  2. AlaskanWolf

    AlaskanWolf Well-Known Member

    Joined:
    Aug 11, 2001
    Messages:
    537
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Fremont CA
    when you go to your url, make sure you have / at the end

    domain.com is not the same as domain.com/ when it comes to hotlink protection
     
  3. SprintSlash

    SprintSlash Well-Known Member

    Joined:
    Jan 18, 2003
    Messages:
    163
    Likes Received:
    0
    Trophy Points:
    16
    Is there a way to make sure domain.com gets redirected to domain.com/ immediately?
     
  4. HankScorpio

    HankScorpio Registered

    Joined:
    Feb 26, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I got it working :D

    $50 and I'll tell you how.............;)
     
  5. sewebhosting

    sewebhosting Member

    Joined:
    Feb 26, 2003
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    please tell me :(
     
  6. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    Add the following to an .htaccess file and place it in Document Root for the account in question.

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://your_domain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.your_domain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.trusted.com/.*$ [NC]
    RewriteRule .*\.(gif|jpg|)$ - [F,L]

    The 'RewriteRule' is where you include the same file extension of the files to be protected.

    Using what was previously mentioned:

    RewriteRule .*\.(gif|jpg|mp3|m3u)$ - [F,L]

    The above code is case-sensitive and works with most Servers -- but not all -- depending upon the OS used and setup.
     
  7. HankScorpio

    HankScorpio Registered

    Joined:
    Feb 26, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    This is the cPanel forum.
    The problem as stated is that cPanel hotlink protection does not work.
    cPanel does generate an .htaccess file for you via the GUI but the way it is formatted means that on some systems, it does not work. That is why the question has been asked here.
     
  8. moronhead

    moronhead Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    706
    Likes Received:
    0
    Trophy Points:
    16
    OK, where do you want me to send you the 50 bucks? :D
     
  9. SoftmegUK

    SoftmegUK Well-Known Member

    Joined:
    Feb 13, 2002
    Messages:
    372
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    he says he would prefer if you sent it to my paypal account first :p
     
  10. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    Yo, stick a sock in it or answer the question asked -- either one will do nicely, thank you. :D
     
  11. HankScorpio

    HankScorpio Registered

    Joined:
    Feb 26, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    The .htaccess file that cPanel generates has extra whitespace at the end of some of the lines, on the four cPanel domains I have or had, when the lines are trimmed back to the last character, it worked for me.
    I can't explain why, I can only say that it does.

    Robs example would work fine if you created your own but like many people, I initially didn't know about the .htacess file and I wanted it to work from the GUI. I spent a lot of time looking into the problem, cutting and pasting and generating new files, testing etc.
    The solution above was what I found worked.

    Apologies if the tone in the previous posts was offensive, the inital post did have a ;) in it and Rob's first post offered a solution but not a cPanel solution which is what people here are looking for.
     
  12. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    Apologies accepted (although not required) and my compliments on a much better answer! ;)

    The only difference between your suggestion and and mine is that I went by the question: "Correct way to use Hotlink protection" whilst you appended: "when using the Cpanel Hot Link feature."

    As the original question was months old and the poster may not know there has been updates to it, we may never know if the Hot Link prevention feature of Cpanel was the problem. As the most recent post, which is what I responded to, simply stated: "please tell me", that's exactly what I did -- and it will work regardless of using/not using Cpanel.

    Your answer, Hank, allows people to use an 'either / or' solution and, between our two answers, they now have the best of both worlds. :D
     
  13. Crazy Pete

    Crazy Pete Well-Known Member

    Joined:
    May 16, 2003
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    6
    What does the L do in this command? On my server it breaks every single image, so they always just show up as the broken image icon. It I just have the F it works, however.

    cPanel.net Support Ticket Number:
     
  14. NightHawk

    NightHawk Member

    Joined:
    Apr 17, 2003
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    well..if you want a way to do it outside of cpanel...but that will work....and you don't want to modify the .htaccess listed above...then you could always just do it the easy way....goto this url: http://www.htmlbasix.com/disablehotlinking.shtml ..fill in the blanks..and use the .htaccess it generates....

    hope that helps :cool:

    cPanel.net Support Ticket Number:
     
  15. Crazy Pete

    Crazy Pete Well-Known Member

    Joined:
    May 16, 2003
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    6
    Thanks very much for that link, NightHawk! That's pretty cool. Turns out it was working after all, but that might help in the future anyhow.

    cPanel.net Support Ticket Number:
     
  16. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    The 'L' stands for Last, as there can more than one Rewrite rule. Leaving it off, if you only have one rule such as in this case, is no biggee and does not change how the rest of the code works.

    The 'F' in case you were wondering, stands for Fail. Some people like to use 'R' (for Redirect), but I don't follow that philosophy and just want to stop the bandwidth thieves -- period!

    BTW, nice link you posted there,
    NightHawk. Should help those that are having problems and not sure what to do.

    cPanel.net Support Ticket Number:
     
  17. Crazy Pete

    Crazy Pete Well-Known Member

    Joined:
    May 16, 2003
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    6
  18. infinityws

    infinityws Well-Known Member

    Joined:
    Feb 20, 2003
    Messages:
    110
    Likes Received:
    0
    Trophy Points:
    16
    Everything on my end is working great, but the things I want to protect are realvideo clips. However to download them it goes through a counter script which, when hotlink protection is active, won't work.

    cPanel.net Support Ticket Number:
     
  19. NightHawk

    NightHawk Member

    Joined:
    Apr 17, 2003
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    have you tried listing the counter script as a referrer in your hotlink .htaccess ??

    cPanel.net Support Ticket Number:
     
  20. outie

    outie Member

    Joined:
    Mar 22, 2003
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Speaking of hotlink protection... one of my clients has a huge traffic site. His site is for image upload and some large forums link the images from his site.

    He used hotlink protectioin to protect other people from linking images from his site (to save bandwidth) and directed them all to one single image file.

    This created a huge server load on my server (70% on a p4 1.7). Is that normal or he didn't do it right? When he removed the redirect protection it was down to 1% load.

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page