Paste the code below into the htaccess file:
<FilesMatch "\.(txt)$"> Order Deny,Allow Allow from all </FilesMatch>
This will allow access to all txt files. If you want to refuse all but one specific file:
Order Deny,Allow Deny from All <Files "view_only_this_file.txt"> Order Deny,Allow Allow from All </Files>
source share