I've modified my .htaccess to redirect hotlinking of images from my site, and I wanted to do something similar with PDF files. In essence when a link comes from outside my site trying to access a PDF file, I want them redirected to a certain page on my site. Currently I have this:
This doesn't seem to be working though. I looked up a PDF from my site through Google and it still opens the PDF rather than redirecting. I have read some on that the redirect needs to go to something of the same mime type, so I may have to create a hotlink.pdf to redirect to, but would prefer sending them to an actual page.
If you have an idea of how to resolve the above, or know of a better technique to do what I'm wanting let me know.
Code:
### Incoming links to PDF files get redirected to publications page
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$ # blank referrer OK
RewriteCond %{HTTP_REFERER} !mysite\.com [NC] # from ymsite OK
RewriteRule ^.*/articles/.*\.pdf$ /publications.php [R]
This doesn't seem to be working though. I looked up a PDF from my site through Google and it still opens the PDF rather than redirecting. I have read some on that the redirect needs to go to something of the same mime type, so I may have to create a hotlink.pdf to redirect to, but would prefer sending them to an actual page.
If you have an idea of how to resolve the above, or know of a better technique to do what I'm wanting let me know.