Skip to content

Instantly share code, notes, and snippets.

@chtzvt
Last active December 30, 2017 21:00
Show Gist options
  • Save chtzvt/01ba4d64730f76f2ec08 to your computer and use it in GitHub Desktop.
Save chtzvt/01ba4d64730f76f2ec08 to your computer and use it in GitHub Desktop.
This bit of lighttpd configuration is what I use to stop image hotlinking, while also ensuring that search engines and social media can still access images.
###Hotlinking madness :^)
$HTTP["host"] =~ "charltontrezevant\.com" {
$HTTP["referer"] !~ "charltontrezevant|ctis\.me|google|bing|facebook|twitter|reddit|ycombinator|Skype|Slack" {
$HTTP["useragent"] !~ "Google|msnbot|FlipBoard|Bing|Yahoo|Facebook|Yandex|twitter|Slack|Skype" {
$HTTP["url"] =~ "\.jpeg|\.jpg|\.png|\.gif|\.bmp" {
$HTTP["url"] !~ "hotlinking\.png" {
url.redirect = ("" => "https://www.charltontrezevant.com/resources/images/hotlinking.png")
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment