M
M
maxxxixxxx2014-07-10 00:28:40
PHP
maxxxixxxx, 2014-07-10 00:28:40

How to close access to folders and files from the .htaccess browser, but leave it for scripts and the server?

There are several folders with subfolders on the server.
They contain scripts.
How can you block access to folders and files using the .htaccess file so that when you type the address in the browser it shows that such a file or folder does not exist on the server?
I would like not to produce configuration files in each folder, but to create a rule in the root of the site.
So far I have found such a code, but it also denies access for the server, in general it does not work.

<FilesMatch ~ "\.(php|htm|html|js)$">
  Order allow,deny
  Deny from all
</FilesMatch>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Entelis, 2014-07-10
@DmitriyEntelis

Not really understood a phrase "prohibits access and for the server". Clarify please.

D
Dmitry Cherednichenko, 2014-07-10
@likeapimp

Try using Directory instead of FilesMatch

S
Sergey Nikolaevich, 2014-07-10
@Playmore

Write a redirect of all requests to index.php in it, create a constant, and in your scripts check whether it exists (if not defined then 404) folders are closed either with an empty index.html or with the Options -Indexes htaccess.net.ru/doc/ rule htaccess/options.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question