Lets say I have a plain text file
Yes, this is easy to do.
There are two main ways to stop users from accessing
example.txt. The first is to put it in a folder outside your web folder (Usually called
public_html), the second is to put a
.htaccess file in the folder with your example.txt script which blocks access to the file altogether. The
.htaccess would look like
<files "example.txt"> deny from all </files>
But you could change
example.txt to something like
*.txt if you wanted to block all
.txt files in the folder.