samoht Posted May 13, 2009 Share Posted May 13, 2009 Hello all, I have a directory on my server that I would like to protect so that people cannot open and see the files - easy enough - But I also need to access these files from within my site using a require_once () or an include() but if the files and directory are protected How can I?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/157954-require_once-with-security-concern/ Share on other sites More sharing options...
jackpf Posted May 13, 2009 Share Posted May 13, 2009 PHP doesn't include the files over HTTP request so it doesn't matter if you protect them. Quote Link to comment https://forums.phpfreaks.com/topic/157954-require_once-with-security-concern/#findComment-833131 Share on other sites More sharing options...
samoht Posted May 13, 2009 Author Share Posted May 13, 2009 OK, Then how do I give access to files in this directory only from other files in the site (no direct access)? Quote Link to comment https://forums.phpfreaks.com/topic/157954-require_once-with-security-concern/#findComment-833140 Share on other sites More sharing options...
JonnoTheDev Posted May 13, 2009 Share Posted May 13, 2009 By moving the directory outside of the website document root i.e # document root public_html # includes directory public_html/includes to # document root public_html # includes directory includes You can still include files from the includes directory in your scripts using the correct path however there is no access publically i.e http://www.xyz.com/includes Quote Link to comment https://forums.phpfreaks.com/topic/157954-require_once-with-security-concern/#findComment-833147 Share on other sites More sharing options...
samoht Posted May 13, 2009 Author Share Posted May 13, 2009 Thanks Neil - of course that would make sense Quote Link to comment https://forums.phpfreaks.com/topic/157954-require_once-with-security-concern/#findComment-833156 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.