My Frugal Tech

  • Home
  • About
  • Services
  • Contact

Identify and Stop Image Hotlinking with Awstats

August 22, 2011 by Mitchell Wischmann

I'm sure many of you are familiar with the term image hotlinking. It's when someone links to your image and uses up your bandwidth. It's very frustrating, because many times, these hotlinkers are not crediting you, and they may also make you exceed your bandwidth limit.

There is a stats tracking application installed on most of your web servers that can help identify and stop hotlinkers. It's called AWStats, and should be available right from your cPanel.

First, we're going to enable AWStats. To do so:

  1. Log in to your cPanel. Most of the time, you can go to www.yoursite.com/cpanel, or this link is likely in an email your host sent you.
  2. Scroll down to the Logs section and click Choose Log Programs.
  3. Check the box underneath AWStats and click Save.

Now, click on the AWStats button, and click on the magnifying glass next to your site name. You should see some stats in this new page. You're now ready to insert the code to track hotlinkers.

To insert the code to track hotlinkers:

  1. Return to your cPanel, scroll to the Files section, and click on the File Manager. If a box pops up, make sure you select Home Directory, then click Go.
  2. A new window will open with your file manager loaded. Double click on the tmp directory and double click on the awstats directory.
  3. Select the file named "awstats.sitename.com.conf" and click Edit in the toolbar. Click on the Edit button in the pop up box.
  4. Search for "AllowToUpdateStatsFromBrowser". Change that line so it reads as follows:

    AllowToUpdateStatsFromBrowser=1

  5. Scroll all the way to the bottom of the file and paste this code in, making sure to change the domain name:
  6. #
    # hotlink
    #
    ExtraSectionName1="Hotlinking pages"
    ExtraSectionCodeFilter1="200 304"
    ExtraSectionCondition1="URL,\.mpeg$||URL,\.mpg$||URL,\.avi$||URL,\.jpg$||URL,\.gif$||URL,\.png$||URL,\.bmp$||URL,\.jpeg$"
    ExtraSectionFirstColumnTitle1="Referrer"
    ExtraSectionFirstColumnValues1="REFERER,^(?!http:\/\/www.sitename.com)http:\/\/(.*)$"
    ExtraSectionFirstColumnFormat1="<a href='http://%s' target='_blank'>%s</a>"
    ExtraSectionStatTypes1=HBL
    ExtraSectionAddSumRow1=1
    MaxNbOfExtra1=25
    MinHitExtra1=1
  7. Click Save Changes in the upper right corner, then close the file editor.

You're all set to track hotlinkers! To see who is hotlinking your images, follow these steps:

  1. From your cPanel, click on AWStats.
  2. Click on the magnifying glass next to your site.
  3. Next to where it says Last Update, click on the Update Now link.
  4. Look in the bottom left corner for a link that says "Hotlinking pages". This is where you see the hotlinkers! Click "Full list" to see the complete list.

Once you have identified the hotlinkers, you might consider sending them an email telling them about what they're doing. Or, you can just block your image from appearing on their site. This is a separate topic and will be covered in an upcoming post.

Filed Under: htaccess, WordPress

Comments

  1. Jaime @ AlittleSaverinthe253 says

    May 8, 2012 at 12:03 pm

    Wow, that was easy. I am glad I followed your link, you have a very simple, yet effective way of explaining things. I know I sound spammy, but I am happy!

  2. Gina L. Sartirana says

    May 8, 2012 at 8:54 pm

    Thank you! Very easy to follow! You are amazing!

  3. Anna says

    May 16, 2012 at 12:14 pm

    You make it seem so easy!

  4. Lynette @ Cleverly Simple says

    May 21, 2012 at 7:29 pm

    Hey Mitchell - I got the following error after following the directions and clicking "update now". Help! 🙂

    Error: The number of values found for extra section 1 has grown too large. In order to prevent awstats from using an excessive amount of memory, the number of values is currently limited to 500. Perhaps you should consider revising extract parameters for extra section 1. If you are certain you want to track such a large data set, you can increase the limit by setting ExtraTrackedRowsLimit in your awstats configuration file.

    Setup ('/home/xxxxxxxx/tmp/awstats/awstats.xxxxxxxxxxxxxxx.com.conf' file, web server or permissions) may be wrong.
    Check config file, permissions and AWStats documentation (in 'docs' directory).

    • Mitchell Wischmann says

      May 21, 2012 at 9:39 pm

      Hi Lynette,

      You should be able to fix this by adding the following line to the awstats.cleverlysimple.com.conf file:

      ExtraTrackedRowsLimit = 1000

      Let me know if that doesn't work!

  5. Gabe says

    October 17, 2012 at 3:51 pm

    Hi Mitchell,

    Thanks for this script, it's terrific and just what I needed. If possible, I was wondering if there was a way that you knew of to add a line to it which would allow it to filter out views triggered by my IP address? Basically, I'm allowing my images to be used on a 3rd party site. However, I frequent these pages often and I'd like to exclude my visits from the data set and only allow visits from IP's other than my own to get added.

    Is there anyway to do this?

    Thanks,

    Gabe

  6. Marc says

    February 4, 2014 at 6:37 am

    Thanks for this! It works great, but I have one banner image which I allow hotlinking for, is there any way to exclude that image one from AWSTATS?

Testimonials

Angie Schuckenbrock

I highly recommend My Frugal Tech! I have requested Mitchell’s services multiple times and I am always extremely pleased with his work. Not only do I feel completely safe allowing him access to my site, but he works quickly and exactly to my specifications. Mitchell definitely knows his stuff and his prices are amazing!!

Angie Schuckenbrock
Frugal 4 Four

Melissa Buckles

I can not say enough good things about My Frugal Tech. I have been impressed with his service and delivery. He made all the changes to my website that I requested quickly and right to my specifications. I give My Frugal Tech two big thumbs up!

Melissa Buckles
Everyday Savvy

Jennie Leanne

Mitchell is simply AMAZING to work with. He understands exactly what I do and exactly what I need which has saved many hours of my time since I’ve started working with him.

Jennie Leanne
Bargain Blessings

Dana Zeliff

My Frugal Tech has helped me with an array of tasks to keep my website running smoothly. The professional service provided to customers is quick and efficient with competitive rates. I highly recommend My Frugal Tech for all your website development and maintenance needs!

Dana Zeliff
The Coupon Challenge

Andrea Deckard

My Frugal Tech consistently delivers timely support and results while creating custom requests that are exactly what I envisioned in my head. Mitchell always acts in the most professional way with his customers’ needs remaining as the priority at all times. He is one of a select few that I trust to provide technical support for my websites.

Andrea Deckard
Savings Lifestyle

Kristie Sawicki

Thanks to the work Mitchell has done for my site I am able to put my focus on what I love most, and that’s writing. I can trust that whatever is broke he is more than able to fix it, and many times in very little time!

Kristie Sawicki
Saving Dollars and Sense

Melissa Garcia

Mitchell is amazing and very talented. I know I can trust Mitchell with my personal information and he is very quick to respond. He is very affordable and he gets the job done. I go to him for all my technical needs.

Melissa Garcia
Consumer Queen

Copyright © 2025 My Frugal Tech. All Rights Reserved.