Anti-hotlink protection for images

I am trying to enable hotlink protection for my image site, among other codes, I have used this one:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?g?|png)$ [NC]
    RewriteCond %{HTTP_REFERER} !^https?://(www.)?domain.es/ [NC]
    RewriteRule \.(gif|jpe?g?|webp|png)$ - [F,NC,L]
</IfModule> 

But it doesn’t work at all. Is there another effective way?

Thanks!

Nginx is used as primary server

1 Like