Jul 24, 2008

How To Stop Image Hot Linking - for a selected directory.

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials
Pages: 1, 2

free web hosting

How To Stop Image Hot Linking - for a selected directory.

Avalon
Those of you that don't know what is meant by 'hotlinking', it is when someone directly links to an image on your site so it will display on their site. This is what is called 'bandwidth theft' and being as accounts here have a limit on bandwidth, your bandwidth limit could be exceeded by someone else hotlinking to your images.

As most users of cPanel will know, there is an option to disable hotlinking of images in the "Site Management Tools" section.
user posted image
However, this disables hotlinking to all directories, what if you only want to disable hotlinking on some directories? Perhaps you want to people to link to some images, say an advertising banner for your site or something similar?

Here's how to do it. Open a text editor like Notepad, copy the code below and paste it into the editor.

CODE
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mudmall.com/.*$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.mudmall.com/img/nolink.gif [R,NC]


Change the domain name where is says, 'mudmall.com' to your domain name and change the 'RewriteRule' line so it has the file extensions you want to deny access to. What I have there will cover most image formats, but you may want to add extensions like 'avi', 'mp3', 'wmv' if you have those types of files. Then change the RewriteRule URL so it points to an image you want displayed when someone tries to hotlink to your file, or you can remove the URL if you don't want to display an image. If you do use an image, make sure it is in an unprotected directory and keep the file size small, mine is only 1.3Kb. Otherwise you will be defeating the purpose of disabling the hotlink.

Finally, save the file with the name '.htaccess', (note the period (.) in front of the name). Now upload this file to the directory/s you want to protect.

This is the end result. Here is an image hosted at Imageshack.
user posted image

Here is the result of trying to hotlink to that same image at my site.
user posted image

I hope you find this useful. smile.gif

 

 

 


Reply

Saint_Michael
hmmm interesting, tutorial me i would have done it the more agressive way spam email boxes report his ip number something like that.

but luckly for me i don't have to many images to be hotlinked.

good job avalon.

Reply

truefusion
QUOTE(Avalon @ Sep 8 2005, 11:08 PM)
Those of you that don't know what is meant by 'hotlinking', it is when someone directly links to an image on your site so it will display on their site.

It's not really only a direct link to an image, but to a file. But, this tutorial is only for images, obviously.

Reply

Avalon
QUOTE(truefusion @ Sep 9 2005, 03:38 PM)
It's not really only a direct link to an image, but to a file. But, this tutorial is only for images, obviously.
*


Thanks for the clarification truefusion, you are of course absolutley correct. The same .htaccess file idea can be used for any file type. But putting an alternate image for the file is pointless if the original file is not an image, as it will not display.

Reply

Mich
QUOTE(Avalon @ Sep 8 2005, 10:08 PM)
Here's how to do it.  Open a text editor like Notepad, copy the code below and paste it into the editor.

CODE
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mudmall.com/.*$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.mudmall.com/img/nolink.gif [R,NC]


Change the domain name where is says, 'mudmall.com' to your domain name and change the 'RewriteRule' line so it has the file extensions you want to deny access to. What I have there will cover most image formats, but you may want to add extensions like 'avi', 'mp3', 'wmv' if you have those types of files. Then change the RewriteRule URL so it points to an image you want displayed when someone tries to hotlink to your file, or you can remove the URL if you don't want to display an image. If you do use an image, make sure it is in an unprotected directory and keep the file size small, mine is only 1.3Kb. Otherwise you will be defeating the purpose of disabling the hotlink.

Finally, save the file with the name '.htaccess', (note the period (.) in front of the name). Now upload this file to the directory/s you want to protect.

*

Got it, thanks!

My husband was awake so I was able to print it off for future reference. I don't know about adding copies of this file to every folder, as I have so many. For now I am going to stick to using my cPanel hot link protection.

 

 

 


Reply

Richard
they this seems cool for my new site. i would use this now but people havent hotlinked me yet

Reply

smartbei
lol...Nice. I need to learn how to use the .htaccess page with all the errors and things...

Reply

rogeruk
Nice tutorial, gonna come in handy with my upcomming website. Nothing fancy but hot linking images, stealing bandwith etc its all good.

Thanks for the tut. good work

Reply

Kioku
QUOTE
Nothing fancy but hot linking images, stealing bandwith etc its all good.


Having one's bandwith slashed down isn't a good thing. rolleyes.gif

Anyway, if I recall correctly, CPANEL's method is the way easier than the alternative method. This guide should help people from having their bandwith totally messed with, though I'd imagine. Good job.

Reply

Avalon
Yes, cPanel's method is much simpler, but like I pointed out in my first post...
QUOTE
However, this disables hotlinking to all directories, what if you only want to disable hotlinking on some directories? Perhaps you want to people to link to some images, say an advertising banner for your site or something similar?

This is the whole point of the alternative method.

Reply

Latest Entries

kurtis
Oh my god! Thank you very much, I have been looking for this everywere, and this is perfect. Keep up the good work, and nice job posting the pictures, they really helped.

Reply

LevinZ
great, so that i can avoid links to warez,etc.....and other illegal stuffs

Reply

da96
hot links gonna be too bad for the websites i hate hot links

Reply

WindAndWater
Canada, this script can be used with pretty much any webserver. Simply save it as .htaccess, and use a ftp (or scp) program to upload it to your website like you'd upload a normal image or html file. It will be effective for the directory you upload it to, and to all of its subdirectories.

Reply

Canada Eh895
Can this script be used for things other than through cPanel? If so, how would I go about installing it? If not, is there a script out there that can do the same thing?

Great script, though

Canada Eh895

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Recent Queries:-
  1. hot to change image border colour - 84.34 hr back. (1)
Similar Topics

Keywords : stop, image, hot, linking, selected, directory

  1. Background Image Swap Script
    Change a Background Image based on clock time (15)
  2. Php Linking
    One of the major advantages of PHP is the ability to create something (4)
    PHP Links Requirements 1. You should understand the majority of PHP (ex: variables, echo, etc.
    www.w3schools.com is a good reference). 2. Experienced with HTML. 3. You need a PHP compatible
    server if you wish to see your results. Description One of the major advantages of PHP is the
    ability to create something similar to an Iframe, only without the scroll-bar. The main advantage of
    this is that you only need one layout page, while the others can be simple 'white space &
    content' pages. Another advantage of this is your web site doesn't look like a fi....
  3. Image Rotator Script (another One)
    easy to implement (0)
    In case you haven't noticed, I have a different Avatar display on the Forum each time the page
    is refreshed. /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif"
    /> For those of you who might want the script to do that, here is the one I am using: HTML
    $filesp = glob('*.png'); if(empty($filesp)){ echo
    'no images found...die br >'; die(); } else{ foreach ($filesp as
    $file) { $img_array[] = trim($file); }....
  4. Math Captcha Image Validation
    (1)
    This tutorial will show you how to make a basic math CAPTCHA validtion form. This requires that you
    have the GD library for PHP installed to work. This tutorial requires 2 files, login.php and
    action.php. The first step is to create a sub-folder to store the temporary images, for the
    purposes of this tutorial,this folder should be called images. Now upload a image in there called
    verify.php and chmod just that image(not the folder) to 777 so that image can change as our
    functions generate new images. Ok, after you've done that, we can get to the code: in login.p....
  5. A Simple Php Captcha - Image Validation
    (21)
    OK, I recently had the need to create a PHP CAPTCHA system for a friend, and I am sharing this as a
    tutorial with the good people here at Trap17. I am sure you have all seen a CAPTCHA before (although
    you may not have known what it was called). They are the little codes you often have to enter when
    you register with a site, to make sure you are a person and not an automated script. Some common
    examples look something like this: My system doesn't really do anything as fancy, but I
    think that it is slightly more readable that some of those that get generated. Every....
  6. Prevent People From Linking To Your Downloads
    (5)
    Ever find that found some people are listing items, images and tuts and linking directly to the
    download url (those that are like image.php?id=0). To prevent this, you can add a piece of code to
    the download pages that checks which page referred them to the download page: if it's your
    domain, it downloads the file normally, if it's not, it will redirect to your home page instead.
    Important: Not all browsers log referrers, so this won't work depending on the browser the
    visitor uses and this method can be also bypassed, but it will work for for the major part....
  7. Image Gallery Tutorial Using Hoverbox
    A php solution to coding the Hoverbox Image Gallery (14)
    As reported in another posting , there is an Image Gallery named Hoverbox from the Sonspring site
    which is a pretty cool display method using CSS to have Thumbnail pictures double their size by
    hovering over them. I liked the css included in the original Tutorial as found on the Sonspring
    site , but I knew there was more than one use for the Hoverbox and took it upon myself to explore
    the use of the Hoverbox on a site I webmaster. One thing that wasn't right was having to
    hardcode the image tags, so the first version I wrote used php to fill the Hoverbox by rea....
  8. Check Referrer To Prevent Linking Yours From Other Sites
    Check referrer with Php and Mysql (8)
    Check Referrer Using Php To Prevent People Linking To Your Downloads From Other Sites Ever
    find that found some people are listing items, images and tuts and linking directly to the download
    url (those that are like my photoshop tutorial.php?id=0), which is a .php to count the number of
    downloads. To prevent this, you can add a piece of code to the download pages that checks which page
    referred them to the download page: if it's my domain, it downloads the file normally, if
    it's not, it will redirect to my home page instead. Important : Not all browser....
  9. How To Make Image To Highlight When It`s Mouseovered
    (8)
    Place this code between and tags. CODE <script
    language="JavaScript1.2"> <!-- function makevisible(cur,which){
    strength=(which==0)? 1 : 0.2 if (cur.style.MozOpacity)
    cur.style.MozOpacity=strength else if (cur.filters) cur.filters.alpha.opacity=strength*100 }
    // --> </SCRIPT> Place the following code within all of the image tags you'd
    like the effect to be applied. CODE
    style="filter:alpha(opacity=20);-moz-opacity:0.2"
    onMouseover="makevisible(....
  10. How To Protect A Directory From Being Viewed
    without admin username and password (4)
    Well i ran across this script awhile back, and i am tired of storing it on my computer, so i am
    going to post it here and whenever i need it i will come here and get it /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> hopefully Anyways, it is a
    verry simple process just copy and paste this QUOTE if (($user) && ($passwort)) {
    # get url $url = $DOCUMENT_ROOT . dirname($PHP_SELF) . "/.htpasswd"; # make
    .htaccess and .htpasswd $htaccess_txt = "AuthType Basic" . "\n"; $htaccess....
  11. Php Script To Make A Link List
    From the list of the Directory Files (6)
    Well, it has been a while since I have added anything to the Tutorial Sectiion, so here is another
    script for the members to enjoy. This one creates a list of links from the contents of the directory
    which it is run from. For instance, if you run it from the public_html folder, then all the files
    (not the Directores) are listed and linked so when you click on the link, that file is parsed and
    output to the browser. Here is the code: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    An XHTML 1.0 Strict Page to List the files in this directory ....
  12. Image Shack Mod
    For Invision Power Board (2)
    Image Shack Mod For Invision Power Board ''These instructions will help you to install
    'ImageShack on your Site' into the reply, quick-reply, and post-new-thread sections of your
    Invision Power Board, thus giving your visitors the ability to upload images directly. After upload,
    they may paste the images directly into their post box.'' CODE These instructions will
    help you to install 'ImageShack on your Site' into the reply, quick-reply, and
    post-new-thread sections of your Invision Power Board, thus giving your visitors the ability ....
  13. Creating A Simple Image Viewer
    Using Visual Basic 2005 Express Edition (3)
    I downloaded Microsoft's Visual Studio Express suite a few months ago, but only recently got
    around to installing it. I have been practising with Visual Basic and making some rather basic
    programs and utilities, but they contain most of the basic concepts. This tutorial will explain how
    to create a basic image viewer, and I will try to explain each step from beginning to end as clear
    as I can. To start you will need: Microsoft Visual Studio About 10-20 minutes free time OK,
    first open up the Visual Basic part of the Studio. I am using the 2005 Express version, so....
  14. Image Rollovers In Javascript
    A Write-Once, Use-Anywhere Approach (11)
    Tutorial: Image Rollovers w/ Javascript, by Rob J. Secord, B.Sc. (SystemWisdom) See a
    working Sample of this Script! Download a ZIP containing all working files in this
    tutorial! Note: If you are not interested in reading this entire tutorial and/or have a basic
    understanding of the underlying concepts, you may safely skip to the Implementation section to get
    the code! Description : A Dynamic Image Rollover Script tested to work in 4 major internet
    browsers: MSIE, FireFox, Netscape and Opera. Using only Javascript combined with regular HT....
  15. How To: Change An Image When A User Clicks On It
    using both php and javascript (11)
    How To: Change An Image When A User Clicks On It using both php and javascript - a powerful
    combination I have seen quite a few how tos offering a method of doing this but none of which
    resembled my method of making use of both php and javascript. This code is fairly repetitive and
    most of the functions are easy to pick-up if you haven't heard of them before. Here it is...
    Create your two images. Call them anything you like, you'd just need to change their filenames
    in $imgano $imgayes. In fact with this script you can easily create more tha....
  16. Making A Webserver Directory Listing
    Helps you organise your webserver (6)
    I recentely installed IIS with PHP and MySQL on my pc (previous I used UniServer, but that
    doesn't matter here). But I had always to go to http://localhost/websiteiwanted or I had to
    create a shortcut on my desktop for every site so I decided to create an "overviewpage". It shows
    all the websites in your wwwroot with a link to them. If you have folders you don't want to be
    included, you extense the && check (but I'll explain this lateron) Here's the total code:
    CODE <ul> <table cellpadding="3" cellspacing="3" border="....
  17. Extending The Image Preloader With Php4
    Dynamically adds your images to Preloader! (3)
    Tutorial: Extending the Image Preloader with PHP4, by Rob J. Secord, B.Sc. (SystemWisdom)
    Second Tutorial in a Series of 2 Tutorials! Be sure to have read the First One here: "Image
    Preloader With Progress Bar Status" See a working Sample of this Script! (Note: Preloads
    100 images, some images are larger than others, and may take awhile for some people.)
    Description : A Tutorial for Extending the Image Preloader with PHP4 to Dynamically Populate the
    Array of Preloaded Images. This tutorial is the second in a series of 2 tutorials, and assume....
  18. Image Preloader With Progress Bar Status
    Pure Client-Side JavaScript tested in 4 Browsers! (22)
    Tutorial: Image Preloader with Progress Bar, by Rob J. Secord, B.Sc. (SystemWisdom)
    Description : A Tutorial for a Client-Side Image Preloader with Dynamic Real-Time Progress Bar
    Indicator written in JavaScript! Tested to work with 4 Major Internet Browsers: Firefox, MSIE,
    Netscape, Opera (Complete sample solution provided at end of tutorial, just put it on your
    web-server, add your images and go!) Intended Audience : Beginner to Intermediate Web
    Developers. Although this tutorial will cover some advanced aspects of JavaScript, I will try to
    explain....
  19. Roll-over Image Links With Css
    No preloading of images (2)
    Here is a way of having roll over image links without preloading images by using CSS and a table.
    It's very useful for a list of links as in a side bar menu or header. It also solves not having
    to make a seperate image for each different link by placing the desired text over the image. 1.
    First you need an image which comprises of the main link image, the 'mouse over' image link
    underneath plus you can have another for visited links. As for most roll over images, the images
    should be the same size. The above example - button.gif is 100x60px with each lin....
  20. A Little Introduction To 3d Studio Max
    How to make a simple abstract image (9)
    This tutorial will teach you the basics of making abstract images in 3D studio max. In this example,
    I used a simple sphere, and applied the “Noise” modifier. Then, I applied a transparent, blue,
    plastic-like material to spice up the whole thing. Let’s start. First, make a sphere by selecting
    the “Sphere” button in the “Standard Primitives” section, and draw somewhere in the center of the
    perspective view. We will set the size of the sphere later on. The sphere I made looks like this,
    yours can be different in size and color, but the only thing that is important is to....
  21. Easy Image Rotate Tutorial
    (0)
    Well, since I'm new, I don't know what has been posted and what hasn't, so here's an
    easy-to-use php tutorial! CODE <?php @header("Pragma: nocache");
    $URL1="Your Image Source"; $URL2="Your Image Source"; $URL3="Your
    Image Source"; $URL4="Your Image Source"; $URL5="Your Image Source";
    srand((double) microtime() * 1000); $random = rand(1,5);
    if($random == 1) @header ("Location: $URL1")....
  22. Simple Image Rotator
    randomly rotate images (6)
    First, It's really confusing. Do you know any tutorials on Image Manipulation on PHP?
    Here's another simple one: 1. Create a 5 image. 2. Rename them to something like:
    image1.jpg; image2.jpg; and so on... 3. Create your PHP file (rotation.php) 4. Enter the
    following code: CODE <?php header("content-type: image/jpeg");
    readfile("image".mt_rand(1,3).".jpg"); ?> 5. Execute your
    script.....

    1. Looking for stop, image, hot, linking, selected, directory

Searching Video's for stop, image, hot, linking, selected, directory
advertisement



How To Stop Image Hot Linking - for a selected directory.



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE