Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Page 1 of 4 1234 LastLast
Results 1 to 15 of 46

This is a discussion on A weary afternoon of trying to get my htaccess to block hotlinking in the Shared & Semi-Dedicated forum
Much to my surprise I find the lines that blocked image hotlinking vanished from my .htaccess file. Possibly from using Cpanel to modify it instead ...

  1. #1
    JPC Addict richardevanslee's Avatar
    Join Date
    Feb 2003
    Location
    Durham, NC
    Posts
    104

    A weary afternoon of trying to get my htaccess to block hotlinking

    Much to my surprise I find the lines that blocked image hotlinking vanished from my .htaccess file. Possibly from using Cpanel to modify it instead of my text editor. I did catch Cpanel zapping the lines I use to keep out bad user agents.

    I've spent the last couple of hours trying the various examples of using modrewrite to block hotlinking. Every example that worked also blocked images from showing up on my own site. Tried the SetEnv method also without luck.

    I can't remember where I got what I'd been using. All I remember is that it referenced each directory that I wanted protected. That ring a bell with anyone.

    Given all the people that have successfully blocked hotlinking I'm a little embarrassed by my own problems.

    Thanks.

  2. #2
    Jag Veteran dkadave's Avatar
    Join Date
    Sep 2001
    Location
    California, from Hawaii! Gotta love the ocean...
    Posts
    558
    blocking all hotlinking is not really posible. well from what I've tried. I spent a day or so trying all kinds of stuff. And nothing seemed to work. So I said, ah, forget.

    but I'm sure there is a way. since I know lots of these free hosts, you know the one's. The block hotlinking. I just wonder how?
    ------------------------------------------------------------------------------------------------
    http://www.dkanet.com - http://www.vi01.com
    http://www.dkahost.com
    ------------------------------------------------------------------------------------------------
    AIM: dkadave - YIM: dkadave
    E-mail: dkanet@dkanet.com
    ------------------------------------------------------------------------------------------------

  3. #3
    JPC Addict richardevanslee's Avatar
    Join Date
    Feb 2003
    Location
    Durham, NC
    Posts
    104
    I was blocking images successfully. Sadly, since I was secure I started adding them more liberally to my pages. Even without the images I'm constantly at war with bandwidth thieves who swipe my written content. A problem keeping the images from being hotlinked could cause serious bandwidth problems.

    Since I had it working before and scoured Google for examples I'm baffled by my own failure.

  4. #4
    JPC Guru
    Join Date
    Jan 2004
    Location
    I'm right behind you....
    Posts
    389
    Well, I don't usually have hotlinking turned on, but when I need it, the default settings from CP's "Enable Hotlinking" controls work just fine.

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://subdomain.domain.com$ [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]

    Hope that helps, I know it works for me.

  5. #5
    Ron
    Guest
    Put a copy of what Galen suggests into each directory that contains images (or maybe just your public_html folder might work) and ensure that .htaccess has permissions of 644

    "chmod 644 .htaccess"

    Don't know if this'll help, but here it is, FWIW

    Be aware that his version will block empty referrers, so a small percentage of your own visitors won't be able to see your images.

  6. #6
    JPC Addict richardevanslee's Avatar
    Join Date
    Feb 2003
    Location
    Durham, NC
    Posts
    104
    As I said I was on Google and tried that (and a couple of variations of that). Blocked me from seeing the images. What I was doing before blocked hotlinkers and let me see the images as well. If only I could remember what it was (if only I'd been wise enough to have had a backup).

    Thanks.

  7. #7
    Ron
    Guest
    Well, JAG does backups, and for a fee maybe they'd be willing to serve up the file to you.

    The key point from my previous post was to ensure the permissions of 644

    Good Luck

  8. #8
    Just Walking...
    Join Date
    Oct 2002
    Location
    England
    Posts
    436
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://.*.yoururl.com.*$ [NC]
    RewriteRule .*\.*$ http://yoururl.com/stolen.gif [R]

    And don't forget that your 'stolen' graphic must be outside the protected folder!
    Last edited by G.Bloke; 03-31-2004 at 04:59 AM.

  9. #9
    JPC Addict richardevanslee's Avatar
    Join Date
    Feb 2003
    Location
    Durham, NC
    Posts
    104
    I've tried several variations of mod_rewrite and setenv. When I successfully block hotlinking then I can't see the images. My .htaccess is pretty big and it may be that some of what I have going on is interfering with my attempts.

    What I was using before and worked exactly the way I wanted it to required that I specify twice the directories that I wanted protected:

    http://domain.org/images/
    http://www.domain.org/images/

    Don't remember where I got it from and after long stretches with Google haven't seen anything similar.

    Many thanks to those of you who made suggestions.

  10. #10
    Just Walking...
    Join Date
    Oct 2002
    Location
    England
    Posts
    436
    Richard are you sure you've cleared the cache between 'views' this can often give the false impression that either the block isn't working or that it is wrongly blocking legit traffic

  11. #11
    JPC Addict richardevanslee's Avatar
    Join Date
    Feb 2003
    Location
    Durham, NC
    Posts
    104
    Fairly sure. I've tried to vary the hotlinked images I check and I'm two different broswers to try to keep from fooling myself. (Didn't get to sleep last night for unrelated reasons so I wouldn't be surprised if I didn't goof something up from sheer weariness.)

    Thanks.

  12. #12
    Kubla Khan lookout's Avatar
    Join Date
    Aug 2002
    Location
    Orodruin
    Posts
    1,386
    Richard, there's a parallel thread over here that you might find helpful. What GBloke posted is one good way of handling this though.
    The trouble with our times is that the future is not what it used to be.
    - Paul Valery

  13. #13
    JPC Addict richardevanslee's Avatar
    Join Date
    Feb 2003
    Location
    Durham, NC
    Posts
    104
    Tried it again and images were still showing up on Live Journal and a something called ****france.com. I did empty Opera's cache just to make sure.

    And I tried it two different ways: adding it to my root directory .htaccess. I also tried repositioning the lines in my .htaccess. (I have a virtual directory and a list of bad referrers and IPs that I've banned.)

    When that didn't work using just those lines for a .htaccess file in an images subdirectory.

    Thanks for the pointer to the other thread.

  14. #14
    Kubla Khan lookout's Avatar
    Join Date
    Aug 2002
    Location
    Orodruin
    Posts
    1,386
    You could lock things down more if you take out the empty referer line (2nd line of GBloke's example), but I don't recommend it, for reasons stated in the other thread.

    If you do leave it in, you will be leaving yourself open to some, but not all, hotlinking attempts. When testing, make sure Opera and your firewall are configured to send the http referer with your URL requests. Also, you'll need to empty the browser cache each time you test to make sure you're getting clean results.
    The trouble with our times is that the future is not what it used to be.
    - Paul Valery

  15. #15
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    This isn't complicated, guys! It isn't Rocket Science...

    Look, here's a hotlink to an IMG on my site, and a hyperlink to it also.



    http://www.lenon.com/modules/copperm...002/alizee.jpg

    The image should not display and the link should not work either. Is this what you're trying to do?
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

Page 1 of 4 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •