How to protect a file on the web host

I have a PHP script that updates a counter in a file on my website.  Someone recently got into that sub-directory and destroyed the file.  I need to be able to allow users to execute the script, but not allow anybody into the directory so they can farkle things up.

How do I do this?
Who is Participating?
jazzIIIloveConnect With a Mentor Commented:
Could you give the server specification? A linux server or a windows server?

If Linux, the give only the 755 right to the directory with its contents...

You can change permissions for all files and directories within a directory by using the -R option on the chmod command. For example, to setup others read and execute access to all files and directories (and files and directories within directories), you need to type command as follows (i.e. change the modes of the file hierarchies rooted in the files instead of just the files themselves):
# chmod -R 755 directory-name/

Files that you create in the public_html dir must have at least permissions
644 (directories must be 755) or the WWW server will not be able to read
them and they will not be "on the World Wide Web".

Best regards...

futurefilesConnect With a Mentor Commented:
whats the OS? if its windows then you can change the ntfs pernissions to read and execute, if its linux i think you need to chmod the file
Hugh FraserConnect With a Mentor ConsultantCommented:
Does the counter file need to be in a directory that's served by the web server? The app that updates it needs to be able to write to it, but it doesn't need to be in a directory that could possibly be accessed through a browser.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.