Make file readable by CGI but not web browser

208 views Asked by At

I have a text file "data.txt", and based on input to an html form I want to display a single line from that file. My result is delivered by a CGI script which needs to access data.txt, but I don't want a user to be able to type in "data.txt" into their web browser and see the whole file. Is there a simple way to make "data.txt" readable by the CGI script but not accessible by loading it with the browser?

I'm using standard apache on ubuntu. I believe the suexec module can do this, but I'm hoping for a simpler solution just using fancy permissions, chowns, etc. Thanks-

1

There are 1 answers

1
Noah Hafner On BEST ANSWER

Store your datafile outside of the webserver filetree (for apache, check the DocumentRoot).