Lighttpd mod_rewrite Hotlink Protection To Display Image Message
Many of our regular readers like to know more about lighttpd hotlink protection using mod_rewrite. Lighttpd can use HTTP referer to detect hotlink and can be configured to partially protect hosted media from inline linking, usually by not serving the media or by serving a different file.
Lighttpd anti hotlinking configuration - redirect to another media
Open lighttpd.conf configuration file:
# vi /etc/lighttpd/lighttpd.conf
Append following directive to redirect to a default picture called /hotlink.png:
$HTTP["referer"] =~ ".*BADDOMAIN\.com.*|.*IMAGESUCKERDOMAIN\.com.*|.*blogspot\.com.*" {
url.rewrite = ("(?i)(/.*\.(jpe?g|png))$" => "/hotlink.png" )
}
So if anyone from *.blogspot.com linked www.cyberciti.biz/image.png it will be replaced with www.cyberciti.biz/hotlink.png. I've written small script to detect excessive hotlink from log file and ban all those domains. Most types of electronic media can be redirected this way, including video files, music files, and animations etc.
Related: Apache web server user can stop lechers using mod_rewrite / .htaccess rules.
You may also be interested in other helpful articles:
- Lighttpd redirect www.domain.com requests to domain.com or vice versa
- Lighttpd: redirect feed traffic to a Feedburner account
- Lighttpd prevent image hotlinking or leeching or direct linking
- Apache: Redirect http to https Apache secure connection - force HTTPS Connections
- Lighttpd phpBB SEO mod_rewrite rules
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: deny access to hotlinking, hotlink, lighttpd, lighttpd redirect image, lighttpd stop hotlinking, mod_rewrite, referer, stop image hotlinking



Recent Comments
Yesterday ~ 24 Comments
Yesterday ~ 24 Comments
Yesterday ~ 3 Comments
Yesterday ~ 2 Comments
09/05/2008 06:08 pm (2 days ago) ~ 16 Comments