Hot to prevent hotlinking for Nextcloud files shared public

I want to prevent users from hotlinking my shared files, but I could not manage to do it in my .htaccess file, because links end with /download, not .zip or .rar. How can I do that?

I tried this but didn’t work.

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?example.com [NC]
RewriteRule (download)$ https://example.com/dontcopy.png [NC,R,L]

I don’t know how RewriteRule will apply to files without an extension, which is this case. Please somebody help me! :slight_smile:

Just:
RewriteRule /download$ https://example.com/dontcopy.png [NC,R,L]

Perhaps you need an optional / in the end as well.

1 Like