A
A
Arthur Grand2016-01-12 17:23:46
PHP
Arthur Grand, 2016-01-12 17:23:46

How to deny access to php files in .htaccess?

Explain for .htaccess
How can I disable access to all php files, except for index.php, which is in the root?
This gives access to absolutely all indexes

<FilesMatch "\.php">
  Order allow,deny
  Deny from all
  Satisfy all
</FilesMatch>
<FilesMatch "index\.php">
  Allow from all
</FilesMatch>

And this, for some reason, prohibits everything, even when I turn to http://site.ru/
RewriteRule \.php$ - [F]
And what does this dash before the flag actually mean?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Ninja Mate, 2016-01-12
@victorzadorozhnyy

deny from all
you create .htaccess in the directory
or you can disable everything in the main file, and then allow the necessary

<Files ~ "^.*">
  Deny from all
</Files>

<Files ~ "^index\.php|css|js|.*\.png|.*\.jpg|.*\.gif">
  Allow from all
</Files>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question