1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to block specific website from Hotlinking?

Discussion in 'Site & Server Administration' started by enikram, Mar 16, 2015.

Thread Status:
Not open for further replies.
  1. #1
    I have 2 images that seem to be being hotlinked a lot by a number of websites.
    I do not want to implement no-hotlinking for everyone as there are some good websites that do it and provide a proper link to my website. However, a few just steal those 2 images and use them on their VERY spammy websites.

    It would be great if there's perhaps a way to just block those websites from accessing my website and taking anything from it.
     
    Solved! View solution.
    enikram, Mar 16, 2015 IP
  2. #2
    To stop hotlinking from specific outside domains only, such as myspace.com, blogspot.com and livejournal.com, but allow any other web site to hotlink images:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/QHGjyAq.jpg [L]
    Code (markup):
    What this is saying is don't allow myspace.com, blogspot.com and livejournal.com to hotlink to your image files and instead show the imgur image.

    Let me know if you have any questions. If this helps, please like my post. :)
     
    nasium, Mar 16, 2015 IP
    enikram likes this.
  3. enikram

    enikram Active Member

    Messages:
    244
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thank you for your reply. Unfortunately this didn't work :(
     
    enikram, Mar 16, 2015 IP
  4. nasium

    nasium Active Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    90
    #4
    Can you tell me a little bit more about what didn't work? Might help to include your code snippit so I can debug.
     
    nasium, Mar 16, 2015 IP
    enikram likes this.
  5. enikram

    enikram Active Member

    Messages:
    244
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #5
    THANK YOU. It worked!!! Apparently CDN and a ton of caching were prohibiting me from seeing the results right away. Thank you again!!!
     
    enikram, Mar 16, 2015 IP
  6. nasium

    nasium Active Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    90
    #6
    No problem. Glad it worked.
     
    nasium, Mar 16, 2015 IP
  7. enikram

    enikram Active Member

    Messages:
    244
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #7
    also, do you by any chance know how to change it properly for say blogspot websites, since they are individual for each country. ex. example.blogspot.com will be shown in USA whille example.blogspot.co.uk will be shown in the UK.
     
    enikram, Mar 16, 2015 IP
  8. enikram

    enikram Active Member

    Messages:
    244
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Also, it only seems to be working for a website,but not a blog. On a blog, it blocks my own images as well for some reason :(
     
    enikram, Mar 16, 2015 IP
  9. enikram

    enikram Active Member

    Messages:
    244
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #9
    This is what I have in the file in my blog
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?movieposterssale\.eu/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?picphotos\.net/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/QHGjyAq.jpg [L]
    
    Code (markup):
     
    enikram, Mar 16, 2015 IP
  10. nasium

    nasium Active Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    90
    #10
    I don't understand what your asking. Can you explain a little further? Also, have you turned off your caching so you can see your changes in real time?
     
    nasium, Mar 16, 2015 IP
  11. nasium

    nasium Active Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    90
    #11
    Here is the original post since the bot deleted it.

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?movieposterssale\.eu/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?picphotos\.net/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/QHGjyAq.jpg [L]
    Code (markup):
     
    nasium, Mar 16, 2015 IP
    zeropaid likes this.
  12. enikram

    enikram Active Member

    Messages:
    244
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #12
    Yep, all the plugins were off. Once the change was implemented on the blog, that picture of a cat was plastered all over the blog. Upon checking, all other websites were prohibited from linking as well.
     
    enikram, Mar 16, 2015 IP
  13. nasium

    nasium Active Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    90
    #13
    Try this. You don't need to disable plugins.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?movieposterssale\.eu/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?picphotos\.net/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/QHGjyAq.jpg [L]
    
    
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress 
    
    Code (markup):
     
    nasium, Mar 16, 2015 IP
Thread Status:
Not open for further replies.