A
A
Albert Kazan2020-03-08 11:32:10
htaccess
Albert Kazan, 2020-03-08 11:32:10

How to deny access to all .php except index.php?

And in all nested directories. Only index.php from root can be accessed.

htaccess now says this

<Files *.php>
  Order Deny,Allow
  Deny from all
#	Allow from 127.0.0.1
</Files>

<FilesMatch "(?i)((\.php|\.tpl|\.html|\.exe|\.ini|\.log|(?<!robots)\.txt))">
  Order Deny,Allow
  Deny from all
</FilesMatch>

<Files ~ "(index|r)\.(ph?p)$">
  Order Allow,Deny
  Allow from all
</Files>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2020-03-08
@SilenceOfWinter

<Files .*>
    Require all denied
</Files>

D
dodo512, 2020-03-08
@dodo512

If Apache 2.4

Require expr %{REQUEST_URI} !~ m#^(?!/index\.php$).*\.php#

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question