This is essentially a duplicate of this question but with one caveat: I want to deny direct access to all files named index.php below the root directory.
Allow: /index.php
Deny: /application/views/settings/index.php
I know I can use PHP to look for a defined constant or variable, but is it possible to achieve this using .htaccess only? This is what I have so far:
##
# Disallow direct access to files.
#
<FilesMatch "^(.*)\.php$">
Order Deny,Allow
Deny from all
</FilesMatch>
<FilesMatch "^index\.php$">
Order Allow,Deny
Allow from all
</FilesMatch>
Adding a third FilesMatch
to deny "^(.*)/index/index\.php$"
does not work.