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:
- 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.
- Scroll down to the Logs section and click Choose Log Programs.
- 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:
- 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.
- A new window will open with your file manager loaded. Double click on the tmp directory and double click on the awstats directory.
- Select the file named "awstats.sitename.com.conf" and click Edit in the toolbar. Click on the Edit button in the pop up box.
- Search for "AllowToUpdateStatsFromBrowser". Change that line so it reads as follows:
AllowToUpdateStatsFromBrowser=1
- Scroll all the way to the bottom of the file and paste this code in, making sure to change the domain name:
- Click Save Changes in the upper right corner, then close the file editor.
# # 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
You're all set to track hotlinkers! To see who is hotlinking your images, follow these steps:
- From your cPanel, click on AWStats.
- Click on the magnifying glass next to your site.
- Next to where it says Last Update, click on the Update Now link.
- 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.
Jaime @ AlittleSaverinthe253 says
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!
Gina L. Sartirana says
Thank you! Very easy to follow! You are amazing!
Anna says
You make it seem so easy!
Lynette @ Cleverly Simple says
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
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!
Gabe says
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
Marc says
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?