Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess allow .txt files

In a web folder, I currently cannot access .txt files via URL in browser. How can I modify my htaccess file, so that files with type .txt can be accessed via URL in browser?

like image 970
John Avatar asked Oct 19 '12 23:10

John


2 Answers

Insert the code below in htaccess file:

<FilesMatch "\.(txt)$">
  Order Deny,Allow 
  Allow from all
</FilesMatch>

This will permit access to all txt files. If you wish to deny all except one specific file:

 Order Deny,Allow 
 Deny from All 
<Files "view_only_this_file.txt"> 
  Order Deny,Allow 
  Allow from All 
</Files>
like image 115
Sérgio Martins Avatar answered Oct 15 '22 04:10

Sérgio Martins


If adding the settings into your .htaccess file that Sergio mentioned isn't working, you may have to go straight to your VirtualHost entry. and add the rules. I'll let the more experienced apache folks here chime in, but that's where I would go.

like image 41
user916011 Avatar answered Oct 15 '22 04:10

user916011