Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Special Interests > Web Design and Development
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread  
Old Aug 9, 2008, 08:55 AM   #1
angelwatt
macrumors 601
 
Join Date: Aug 2005
Location: Dayton, OH
Redirect hotlink of PDF files

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:

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.
angelwatt is offline   Reply With Quote
Old Aug 11, 2008, 01:04 PM   #2
angelwatt
Thread Starter
macrumors 601
 
Join Date: Aug 2005
Location: Dayton, OH
It was a slow weekend so just want to make sure people saw this post. I haven't resolved it as of yet.
angelwatt is offline   Reply With Quote
Old Aug 11, 2008, 03:13 PM   #3
notnek
macrumors 6502
 
Join Date: Oct 2007
i did some looking around and a list apart looks like they have a good solution for your problem. you could just alter it to redirect to a page.

check it out here.
notnek is offline   Reply With Quote
Old Aug 11, 2008, 05:48 PM   #4
angelwatt
Thread Starter
macrumors 601
 
Join Date: Aug 2005
Location: Dayton, OH
Quote:
Originally Posted by notnek View Post
i did some looking around and a list apart looks like they have a good solution for your problem. you could just alter it to redirect to a page.

check it out here.
Thanks for the link, it's one I've read before as I'm a big fan of ALA, but unfortunately their solution doesn't seem to apply to PDF files. I've got hotlinking blocked for images, css, js, and music files, but it won't work for PDFs for whatever reason.
angelwatt is offline   Reply With Quote
Old Aug 14, 2008, 01:03 PM   #5
notnek
macrumors 6502
 
Join Date: Oct 2007
just curious if you ever found a solution?

after haven't looked, all i find are image hotlink preventions. no file other files types.
notnek is offline   Reply With Quote
Old Aug 14, 2008, 01:15 PM   #6
angelwatt
Thread Starter
macrumors 601
 
Join Date: Aug 2005
Location: Dayton, OH
Quote:
Originally Posted by notnek View Post
just curious if you ever found a solution?

after haven't looked, all i find are image hotlink preventions. no file other files types.
No, not really. There was some reads on streaming the PDF content, but that didn't sound like a great solution. I think the best bet is to have urls like page.php?article=1024, then have PHP correlate that with the actual PDF file and produce it without ever showing a direct link to the PDF file, which would let me place the PDFs in a non-web accessible folder so even if someone knew a direct folder access to the PDF they couldn't do so. I haven't tried this out yet, but seems to be the most straight forward option at the moment. I'm not really worried about people hotlinking my PDFs, I just wanted to make sure they saw my actual site as well, and I like learning more server configurations and how they work.

Why the hotlinking block wasn't working is still bugging me. Not sure if it's a binary file issue, or if its because the PDF has to be loaded through a plug-in and that somehow interrupts information flow between the server redirect and the browser somehow. Thought about testing it out by placing a Windows executable out there and doing a hotlink block on it, but haven't gotten around to it. I could also try with a movie file since those work through plug-ins as well.
angelwatt is offline   Reply With Quote
Old Aug 14, 2008, 02:43 PM   #7
ChrisA
macrumors 601
 
Join Date: Jan 2006
Location: Redondo Beach, California
Quote:
Originally Posted by notnek View Post
just curious if you ever found a solution?

after haven't looked, all i find are image hotlink preventions. no file other files types.
One sure fire, fool proof method is to replace all the files you don't want hot linked with encrypted version of those files. Now there is no need to prevent hot linking,

Then on your publications web page you replace your links with a link to a cgibin file that is passed the filename as input and writes the un-encrypted file to standard out. You don't even need a strong encryption. Any hack will be good enough.
ChrisA is offline   Reply With Quote

Reply

Mac Forums > Special Interests > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:37 AM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 2002-2009, MacRumors.com, LLC