Answer the question
In order to leave comments, you need to log in
How to prevent users from accessing a txt file?
There is txt, you need to set such rights in it so that php can continue to write and read it, and the user could not access it.
Answer the question
In order to leave comments, you need to log in
It is safer to keep the file outside the root of the web server, because suddenly the server will have nginx in front of Apache, and there it will be configured to send static files past Apache. As a result, the server will give this file without checking .htaccess.
In the case of a web user, this is done from within your PHP program.
htaccess, what's in your tags - it has nothing to do with it.
Who is a web user, no one except your PHP program made - and does not know.
Put a period in the name of the txt file. For Apache, all files starting with a dot are prohibited from viewing via the web (.htaccess/.htpasswd is an example of this).
If you need to deny access to a local user on a UNIX system, set the permissions to rw-rw---- (0660). And the user/group that Apache is running under so that PHP running under Apache with that user/group has full access to the file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question