-1

How can I prevent hotlinking specific files from other sites?
Lets say mydomain.com/file1.zip and mydomain.com/file2.zip - I would like to redirect them to pages mydomain.com/file1page and mydomain.com/file2page.
I want to prevent only those 2 of hotlinking not all the zip files.

Havelock
  • 6,913
  • 4
  • 34
  • 42
Badr Hari
  • 8,114
  • 18
  • 67
  • 100

1 Answers1

0

You can check against the referer but those can easily be spoofed. So something like:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://mydomain.com/
RewriteRUle ^/?(file1|file2).zip$ /$1page [L,R=302]

So if the referer doesn't start with http://mydomain.com/ and the request is for either file1.zip or file2.zip, redirect to either file1page or file2page.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220