Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Blocking Hot Linkers |
|
Author |
|
Brian
Joined: 21 Oct 2005 Posts: 209 Location: Puyallup, WA USA
|
Posted: Wed 09 Nov '05 20:44 Post subject: Blocking Hot Linkers |
|
|
Hot linking is nothing more than stealing resources.
SPAM for example does cost us all money, it consumes so much bandwidth each second of each day that ISP's major backbone providers and so on must increase capacity to make sure that we can all access the net, use it for business and non-commercial purposes. If spammers had their way, there would be room only for their junk.
When providers have to invest into higher capacities, they pass that cost onto you and me. That is why I do my part to prevent hot linkers from taking up my valuable bandwidth.
Here is an example of some code that I use to block hot linkers, it would be placed in a simple .htaccess file. Of course this assumes you have mod_rewrite enabled on your server.
Will block those not from a specific IP range, no referer, or from referred from specific domains Code: | RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REMOTE_ADDR} !^209\.240.*$ [OR]
RewriteCond %{HTTP_REFERER} !^http://www.domain1.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain2.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain3.com/.*$ [NC]
RewriteRule .*\.(gif|jpg|png)$ http://www.domain.com/images/replacement.gif [R,NC] |
Will block those not from specific domains Code: | RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.domain1.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain2.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain3.com/.*$ [NC]
RewriteRule .*\.(gif|jpg|png)$ http://www.domain.com/images/replacement.gif [R,NC] |
I am not an expert with mod_rewrite, and it can be used for so many more things than just blocking hot linkers. This terrific module can help with security, routing traffic based on such things as IP, REFERER, and other criteria.
Steffen has much more broad experience with mod_rewrite than I do, but I do know by going through my log files that this little module has been good for blocking hot linkers -AND- advertising my services since the substitute image I offer is in fact a banner advertisement : ) |
|
Back to top |
|
|
|
|
|
|