Unable to make hotlink protection through htaccess

Petsuchos

New member
Joined
Sep 23, 2019
Messages
2
Hi!

I just migrated and after some issues, my site is now working.

But I am unable to make a hotlink protection using the same htaccess I had on cpanel. The code does not allow images to be loaded.

This is my old code line:
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?domain\.com(/.*)?$ [NC]
RewriteRule ^(.*)\.(gif|jpe?g|png|rar|zip|htm)$ /file.jpg?$1.$2 [NC]

Tried these also:

# hotlink protection via stupid htaccess tricks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.tld/.*$ [NC]
RewriteRule .*\.(gif|jpg)$ http://www.domain.tld/file.jpg [R,NC,L]


</ifModule>


and this

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|zip|rar)$ domain.com/file.jpg [NC,R,L]

None worked.
Since they are all 10 years old or so, is there and new code I could use?
Thank you in advance
 
Back
Top