For security, I move the collection of files and folders outside the root web server on the Apache server, and then I will serve them dynamically. This seems to be better than 2 alternative:
- Leave them available on the Internet and just create a php login page that is added to each file. The problem is that these are not all php files, and I cannot add the php input file to pdf, image, etc.
- Leave them available online and use HTTP authentication to restrict access to the entire directory. But this introduces problems, including cleartext passwords, lack of an elegant exit method, etc.
So, we returned to the fact that they were outside the root website, but served them dynamically. The problem I encountered is different types of files (php scripts, txt, pdf, jpg). I am not sure whether to use include() or readfile() . And I am having problems sending the appropriate headers for each file so that the browser displays them correctly.
Did I miss another magic solution? Is there some kind of infrastructure that has eluded me that handles the flow of dynamic files and headers?
(FYI I use Linux, Apache and PHP on a shared host)
Andrew
source share