Hi, I am interested in the code in .htaccess which prohibits reading files from a specific folder, or reading files with a .txt extension if you open them from a browser, or an alternative variant with access rights, currently costs 644.

// this refers to the topic below ..

here, do not want to work together

RewriteEngine on RewriteRule ^index.php$ /az/ [NC,R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php <FilesMatch "\.css$"> Order Deny,Allow Deny from all </FilesMatch> 
  • Questions do not need to be changed after receiving an answer. If there is a new question, then it should be made out separately. - Visman
  • one
    Yes, but since this is an identical topic with the difference only in the file format, when you register a new question, they will also tell me that this is a duplicate of the “current” question - hovdev

1 answer 1

Put in the desired folder (in which you want to deny access to files with txt extension) an .htaccess file with the following contents:

 <FilesMatch "\.txt$"> Order Deny,Allow Deny from all </FilesMatch> 
  • Thanks, doesn't this code forbid all users? mk from me from this folder, php (FAST CGI works from the user), reads contents of these files and brings to the site, it will not stop working? - hovdev 2:51 pm
  • @ S1lllver, if you access files from php as if on a local disk, these prohibitions do not apply. Bans are set for external requests to the server. - Visman
  • checked everything works, there is a certain page where you enter text and all that it changes the contents of this file, to which I actually registered the ban - hovdev
  • but I already checked, everything works, great - hovdev
  • this script, I understand that this is not logical, but it does not work for .css files, which is very strange, there is a basic .htaccess that does redirects and all that, I added to it, but it doesn’t want to prohibit viewing css files, I will write the main .htaccess code above - hovdev