1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Picture hotlink protection not working

Discussion in 'Server Configuration and Hosting' started by TazDevilLooney, Oct 11, 2011.

  1. TazDevilLooney

    TazDevilLooney Active Member

    I wonder if anyone can help me out here. I can't seem to get this hot linking to work. Is it because the picture file does not have the .png or . jpg on the end?

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(. \.)?mysite\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpe?g|gif|bmp|png|jpg)$ /NoHotlinking.png [L]

    /attachments/malware-spreads-as-browser-update-2-jpg.1608/

    Could someone give me a hand with this please. :cry:

    The cheeky website is http://www.cnw.com.cn/security-anti-virus/htm2011/20110926_234622.shtml
     
  2. Brett Peters

    Brett Peters Well-Known Member

    Here is my .htaccess if that helps at all

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?site.com [NC]
    RewriteRule \.(jpg|jpeg|jpe|png|gif)$ http://link to image that is NOT ON YOUR SERVER.png [NC,R,L]
     
    Fuhrmann likes this.
  3. TazDevilLooney

    TazDevilLooney Active Member

    Wow thanks Brett, I have added the code but the picture still displays on the website in question. I'm not sure what's going on :confused:

    This is my current .htaccess

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
        Redirect 301 /forum http://fixitwizkid.com
    </IfModule>
     
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?fixitwizkid.com [NC]
    RewriteRule \.(jpg|jpeg|jpe|png|gif)$ http://fixitwizkid.com/NoHotlinking.png [NC,R,L]
     
  4. Brett Peters

    Brett Peters Well-Known Member

  5. CyclingTribe

    CyclingTribe Well-Known Member

    Does it work if you place it inside the <IfModule mod_rewrite.c> directive wrapper?
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Just an FYI, but generally any additional rewrite rules should be before the XenForo rewrite rules.

    Try moving the code up to just below RewriteEngine On
     
  7. TazDevilLooney

    TazDevilLooney Active Member

    I've tried a number of things but just can't get this to work for me. I did try all that was suggested. <sigh>

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?fixitwizkid.com [NC]
    RewriteRule .*\.(jpeg|jpg|gif|bmp|png)$ http://mtcstorage.co.uk/NoHotlinking.png [L]
    
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
        Redirect 301 /forum http://fixitwizkid.com
    </IfModule>
    
    Hot Linked picture from the site.
    [​IMG]

    This is the example picture i was hoping for everyone else to receive which is located on another server.
    NoHotlinking.png
    I'm really scratching my head here any more idea's.

    Thanks for all of the help guys and sorry for the late reply.
     
  8. George

    George Active Member

    Try this:

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_REFERER} !^$
        RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?fixitwizkid.com [NC]
        RewriteRule .*\.(jpeg|jpg|gif|bmp|png)$ http://mtcstorage.co.uk/NoHotlinking.png [L]
    
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
        Redirect 301 /forum http://fixitwizkid.com
    </IfModule>
    
     
    TazDevilLooney likes this.
  9. TazDevilLooney

    TazDevilLooney Active Member

    Thanks George but did not work ether. I'm using the code now. The forum Rewrite rules are working this is just really odd.
     
  10. TazDevilLooney

    TazDevilLooney Active Member

    Would the hot linking address be something to do with? /attachments/mod3-png.862/

    Why i say that is it's not got the .png on the end.
     
  11. George

    George Active Member

    Try this one:

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_REFERER} !^$
        RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?fixitwizkid.com [NC]
        RewriteRule .*\.(jpeg.[0-9]|jpg.[0-9]|gif.[0-9]|bmp.[0-9]|png.[0-9])$ http://mtcstorage.co.uk/NoHotlinking.png [L]
    
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
        Redirect 301 /forum http://fixitwizkid.com
    </IfModule>
    
    And this one although it may cause errors with other urls.

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_REFERER} !^$
        RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?fixitwizkid.com [NC]
        RewriteRule .*\.(jpeg.*|jpg.*|gif.*|bmp.*|png.*)$ http://mtcstorage.co.uk/NoHotlinking.png [L]
    
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
        Redirect 301 /forum http://fixitwizkid.com
    </IfModule>
    
     
    TazDevilLooney likes this.
  12. TazDevilLooney

    TazDevilLooney Active Member

    Added the code and still not redirecting the pictures. I really do appreciate your help with this George. (y)
     
  13. George

    George Active Member

    Did you try them both.

    P.S. I had to edit the first one because the editor added font size and color bbcode for some reason.
     
    TazDevilLooney likes this.
  14. TazDevilLooney

    TazDevilLooney Active Member

    Yes tryed both, no errors and nothing happing. :confused:
     
  15. TazDevilLooney

    TazDevilLooney Active Member

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_REFERER} !^$
        RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?fixitwizkid.com [NC]
    #    RewriteRule .*\.(jpeg.[0-9]|jpg.[0-9]|gif.[SIZE=14px][0-9]|bmp.[0-9]|png.[0-9])$ http://mtcstorage.co.uk/NoHotlinking.png [L]
      RewriteRule .*\.(jpeg.*|jpg.*|gif.*|bmp.*|png.*)$ http://mtcstorage.co.uk/NoHotlinking.png [L]
    
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
        Redirect 301 /forum http://fixitwizkid.com
    </IfModule>
    
     
  16. TazDevilLooney

    TazDevilLooney Active Member

  17. George

    George Active Member

    Well the first one you have commented out has the
    Code:
    [SIZE=14px]
    in it still.

    And sorry I I dunno what else to do. But yes it has something to do with the numbers on the end and jpg etc. not being there.
     
    TazDevilLooney likes this.
  18. TazDevilLooney

    TazDevilLooney Active Member

    Made the corrections and still the same. I definitely agree with you George with the numbers on the end. I can't see how everyone else's seems to work and mine don't. Can someone provide me some sort of prof that there's works with Xenforo attachments. At this moment i really can't see how it can. Thanks for all your help with this George you a star buddy.
     
  19. CRDeveloper

    CRDeveloper Member

    Edit: I failed!

    TazDevilLooney did you find a way to make this protection to work?
     
  20. TazDevilLooney

    TazDevilLooney Active Member

    Nope, i didn't sorry.
     
    CRDeveloper likes this.

Share This Page