Skip to content

Webinformat

Hot link protection

Simple hot link protection using .htaccess

<IfModule mod_rewrite.c>
 RewriteEngine on
 #RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{REQUEST_FILENAME} -f
 RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
 RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?your-domain\. [NC]
 RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [NC]
 RewriteRule \.(gif|jpe?g?|png|bmp)$ http://your-domain/hotlinkdenied [R,L]
</ifModule>
  • Replace your-domain with your actual domain name
  • Replace http://your-domain/hotlinkdenied with a valid url