First and foremost, I would like to say thank you very much for those who gave me comments and suggestions to my last post. Here, I found two ways how you can prevent someone from hotlinking your files and eating up your bandwitdh.
1st Method – CPanel HotLink Protection
If you use CPanel, you can set and block peoples from hotlinking your files with HotLink Protection option. Just login into your CPanel and click on the HotLink Protection icon. In the HotLink Protection page, you can set which urls you allow for access, file types that you want to protect, url to redirect the hotlinked files and option to allow direct request.
For more clear view about this, I have prepare you with a flash video on how to use the HotLink Protection option. I found this video from my hosting provider FAQ page.
2nd Method – .htaccess
You also can do this with .htaccess file on Apache web server if you don’t have CPanel. Here is how to do it:
- Create file name htaccess.txt
- Place this code in your htaccess.txt file
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/stophotlink.jpe [L]What this code does is it will only allow hotlink files from your domain (mysite.com) and direct request. And if it comes from other domain or request, files with extension .jpeg, .gif, .bmp and .png will be replaced with stophotlink.jpe file.
Note: .jpe is a .jpg image file. We use .jpe because we want to prevent from infinite redirect loop.
- Upload htaccess.txt file into your root server
- Rename the file to .htaccess
- Done!
More info for this second method, you can read this tutorial, How Do I Stop Hotlinking and Bandwidth Theft?
Madhur Kapoor says
Nice info man . I had cpanel all along but didnt pay any attention to this .
CypherHackz says
no problem. i just found out that this thing is good to share. ๐
Bent says
Hi..i’m your new fun member..nice blog huh! i found load of information inside there..keep it up dude! of course for blogger out there!
CypherHackz says
ha3. sure. thanks for your comment. ๐