Skip to content

Instantly share code, notes, and snippets.

@jeremybuff
Last active August 29, 2015 14:19
Show Gist options
  • Save jeremybuff/0cedc21d4697345c4d83 to your computer and use it in GitHub Desktop.
Save jeremybuff/0cedc21d4697345c4d83 to your computer and use it in GitHub Desktop.
Htaccess Hotlink Protection
# Hotlink Protection --------------------------------------------------------------------------------
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png|svg)$ [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?yourdomain\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
RewriteCond %{REQUEST_URI} !^/hotlinking.png$
RewriteRule \.(gif|jpe?g?|png|svg)$ /hotlinking.png [NC,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment