+ Reply to Thread
Results 1 to 3 of 3

Thread: Prevent Hotlinking

  1. #1
    lair360 is offline x10 Sophmore lair360 is an unknown quantity at this point
    Join Date
    Dec 2008
    Posts
    200

    Prevent Hotlinking

    Version: 17.3
    Revision: 42 Build 68

    Blocking Bandwidth Leeches

    Introduction: this source was made for users who would like to block others from linking your images to their forums, blog and search engines.
    You can use this source code to kill those linkers from stealing your own bandwidth!

    1.] Download Notepad++ from this website and install it…
    ---------------------
    http://filehippo.com/download_notepad/

    2.] Copy this source code and save your file as…

    File type: .htaccess

    Notes: save this file as: “All types”

    Warning: you must clear your system cache to see the changes...

    Details: add some of your offending website, blogs or search engines...ect.

    Example…
    --------------------
    RewriteCond %{HTTP_REFERER} ^http://(www\.)?mysite\.com [NC]

    RewriteCond %{HTTP_REFERER} ^http://(www\.)?google\.com [NC]

    Tips: you can cancel out the dashes and use this style instead…
    -----------------------------------
    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)$ /images/nohotlink.jpe [L]
    -----------------------------------

    Single website linking - blocked
    ---Copy Source Code---

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

    ---End Source Code---

    If you want to block multiple websites, you can use this source code which is provided below.

    Notes: the last line on “RewriteCond %{HTTP_REFERER}”, it must have an [NC] codes or it will not work!

    Multiple website linking - blocked
    ---Copy Source Code---

    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)$ /images/nohotlink.jpe [L]

    ---End Source Code---

    Notes: you can also add different extension to enhance your file protection.
    To do this just take a look and compare this code below from the above…

    ---Copy Source Code---

    RewriteRule .*\.( jpeg|jpg|gif|png|mp3|zip|rar)$ - [F]

    ---End Source Code---
    Copyright 2001-2008 Lair360

    Blocking all hotlinker!

    If you want to block hotlinking completely, so that no one can hotlink your files, you can use this source instead of the above.

    Advice: replace some of my trusted website with your own website. After that, just upload the file to your ftp server.

    Warning: if you're going to redirect someone to a different image, that image must not be on your FTP server or you will create an infinite loop!

    ---Copy Source Code---

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?lair360.srhost.info [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?lair360.wordpress.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?stonerocket.net [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]

    ---End Source Code---

    This source is a little lighter and less aggressive. It’s also easy to maintain…

    ---Copy Source Code---

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?lair360.srhost.info/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?lair360.srhost.info/blog/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]

    ---End Source Code---



    This is the final source to allow only trusted website to hotlink your images.
    You must also allow your website on the first line to allow your webpage to upload this images…

    ---Copy Source Code---

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?lair360.srhost.info [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?lai360.srhost.info/blog/ [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?stonerocket.net [NC]
    RewriteRule \.(jpg|jpeg|png|gif|zip)$ - [NC,F,L]

    ---End Source Code---

    Notes: you can also change one of the “RewriteRule” to forbid users from stealing your images and bandwidth.

    ---Copy Source Code---

    RewriteRule \.(jpeg|jpg|gif|png|mp3|zip|rar)$ /images/nohotlink.jpe [L]

    RewriteRule \.(jpeg|jpg|gif|png|mp3|zip|rar)$ - [F]

    ---End Source Code---
    Copyright 2001-2008 Lair360

    To block Search engines, you can use this instead…

    Notes: it will not block all of the search engines. This example will only block yahoo, google and askjeeves.

    ---Copy Source Code---
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?google.com [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?yahoo.com [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?askjeeves.com [NC]
    RewriteRule \.(jpg|jpeg|png|gif|zip)$ - [NC,F,L]

    ---End Source Code---
    Copyright 2001-2008 Lair360

    This is another alternative, you can also use this source code…if you desire…

    Allowing multiple sites and block all other sites.
    ---Copy Source Code---

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?you\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?ok1\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?ok2\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpg|jpeg|gif|bmp|png|swf)$ - [F]

    ---End Source Code---

    Allowing one site and block all other sites.
    ---Copy Source Code---

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?you\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpg|jpeg|gif|bmp|png|swf)$ - [F]

    ---End Source Code---

    Here is the bonus and it also works!
    ---Copy Source Code---

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(.*\.)?lair360.srhost.info [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.*\.)?lair360.wordpress.com [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.*\.)?stonerocket.net [NC]
    RewriteRule .*\.(jpg|jpeg|png|gif|zip|rar)$ - [F]

    ---End Source Code---

    This source code is a little different. But, it’s only for advance user...

    ---Copy Source Code---

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain1.com(/)?.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain2.com(/)?.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain3.com(/)?.*$ [NC]
    RewriteRule .*\.(gif|jpg|png)$ - [F]

    ---End Source Code---

    Notes: looking at the above source code, you will need to replace domain1, domain2 and domain3 with your own trusted website.

    As I’ve said this before, you can use this code below instead of using the [F] command.

    ---Copy Source Code---

    RewriteRule .*\.(jpeg|jpg|gif|png|mp3|zip|rar)$ /images/nohotlink.jpe [L]

    ---End Source Code---
    Copyright 2001-2008 Lair360

    Notes: you can also add more extension to enhance your file protection…

    ---Copy Source Code---
    RewriteRule .*\.(jpeg|jpg|gif|png|mp3|zip|rar)$ - [F]

    RewriteRule .*\.(gif|jpg|jpeg|png|mp3|mpg|avi|mov|wmv|doc|xls| swf|fla)$ - [F]

    ---End Source Code---
    Copyright 2001-2008 Lair360

    Enjoy your experiment and have fun blocking these bandwidth idiots!

    Lair360
    Last edited by lair360; 12-04-2008 at 01:47 AM.

  2. #2
    compwhizii is offline Banned compwhizii is an unknown quantity at this point
    Join Date
    May 2008
    Location
    The Moon
    Posts
    779

    Re: Prevent Hotlinking

    Cool, thanks for the tutorial. Next time use code tags for the code

  3. #3
    Sohail's Avatar
    Sohail is offline x10 Spammer Sohail is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    London, UK
    Posts
    3,052

    Re: Prevent Hotlinking

    I think we have a feature in the cPanel that does this automatically once activated but nice tutorial anyway.

+ Reply to Thread

Similar Threads

  1. Replies: 4
    Last Post: 02-20-2008, 06:13 AM
  2. Que es hotlinking?
    By yaxiiah in forum General
    Replies: 9
    Last Post: 01-31-2007, 08:39 PM
  3. help with hotlinking
    By NewFuture in forum Free Hosting
    Replies: 12
    Last Post: 07-13-2005, 11:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers