Protect/hide file
Hey,
I have a file on my server that I do not want being accessible by the public. How would I be able to protect it?
I have a PHP script calling the file using file(), and this returns a Permission Denied error if I CHMOD the file to 640.
So, I need the file to be available only to the script, and nothing else. Any ideas? (I'm not very familiar with file management etc.)
Thanks,
Abhishek.
zollet posted this at 08:32 — 27th June 2002.
He has: 1,016 posts
Joined: May 2002
The safest way is to place this file _outside_ of your public_html directory. A second way would be to rename this file to ".whatever" (filename starts with a dot). This will make it not show in the directory listing, but still available if someone knows it exists and types in the full path (i.e. domain.com/.whatever).
Abhishek Reddy posted this at 08:54 — 27th June 2002.
He has: 3,348 posts
Joined: Jul 2001
Thanks for the reply. I am already using the .name thing... and I don't have access to anything outside the public dir. Oh well.
zollet posted this at 09:30 — 27th June 2002.
He has: 1,016 posts
Joined: May 2002
Another thing you could do is to name it filename.cgi or filename.pl. This way, if someone tries to load it, it will get a 500 error.
Abhishek Reddy posted this at 12:21 — 27th June 2002.
He has: 3,348 posts
Joined: Jul 2001
Thanks mate.
zollet posted this at 15:11 — 27th June 2002.
He has: 1,016 posts
Joined: May 2002
You're welcome. I'm glad I could help.
ROB posted this at 01:07 — 29th June 2002.
They have: 447 posts
Joined: Oct 1999
if you name it .htwhatever it will not be web accessible at all, apache will not serve it (assuming your server is running apache)
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.