rondog Posted August 27, 2008 Share Posted August 27, 2008 I have a directory with some PDFs. Once a user logs in they have access to these links. My problem is google has indexed these PDFs and I know robots.txt will help with that, but what about other search engines? Can I use PHP to restrict access to the PDFs unless a user is logged in? Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/ Share on other sites More sharing options...
discomatt Posted August 27, 2008 Share Posted August 27, 2008 Store them outside of webroot, and serve them to the user with PHP Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/#findComment-627247 Share on other sites More sharing options...
rondog Posted August 27, 2008 Author Share Posted August 27, 2008 They are outside of the webroot..the site is like so: www.site.com/client/index.php the pdfs: www.site.com/client/docs/some_pdf_file.pdf yet google still finds them. Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/#findComment-627258 Share on other sites More sharing options...
akitchin Posted August 27, 2008 Share Posted August 27, 2008 by outside of the webroot, he means ABOVE the webroot. that is, if your webroot location is: /usrs/username/local/public_html/ then you'll want to toss them in: /usrs/username/local/ Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/#findComment-627260 Share on other sites More sharing options...
DarkWater Posted August 27, 2008 Share Posted August 27, 2008 That's not out of the webroot, rondog. =/ --Aww, akitchin beat me to it. D: Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/#findComment-627261 Share on other sites More sharing options...
rondog Posted August 27, 2008 Author Share Posted August 27, 2008 ohh ok gotcha so for a link I would just do ../../ etc? Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/#findComment-627263 Share on other sites More sharing options...
DarkWater Posted August 27, 2008 Share Posted August 27, 2008 ohh ok gotcha so for a link I would just do ../../ etc? No, you'd need a PHP file to serve the PDFs because they won't be accessible at all from the browser. Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/#findComment-627267 Share on other sites More sharing options...
rondog Posted August 27, 2008 Author Share Posted August 27, 2008 ok I am doing: <?php $file = "../../pdfs/policy.pdf"; header("Content-type: application/pdf"); header("Content-Disposition: inline; filename=\"policy.pdf\""); readfile($file); ?> and its force downloading the pdf..I want it to just open in the browser..any idea? Link to comment https://forums.phpfreaks.com/topic/121600-protecting-some-pdfs/#findComment-627288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.