I want to block access to "sub/folder/index.php", but not "index.php" anywhere else.
<Files index.php>
Order allow,deny
Deny from all
</Files>
works but blocks all "index.php" files.
<Files sub/folder/index.php>
Order allow,deny
Deny from all
</Files>
doesn't work. Do I need to use <Directory>
?
I don't want to create an .htaccess file in the sub/folder
I don't have access to httpd.conf
I don't want to block everything in sub/directory
If it were that easy, I wouldn't be asking ;)
You can add a . htaccess file to any directory that requires lenient permissions settings (such as 760, 766, 775 or 777). You can prevent the execution of scripts inside the directory and all its sub-directories.
Create a . htaccess file in the root of your project directory structure. Then open the . htaccess file and write this directive deny from all.
htaccess to make it happen. For example, deny from all is a command that will allow you to apply access restrictions to your site.
I think the simpliest rule is:
RedirectMatch 403 ^.*/sub/folder/index\.php$
RedirectMatch is in mod_alias module, that you certainly have. This does not implies mod_rewrite engine. Here we are simply telling apache that any access to sub/folder/index.php will generate a "403 forbidden" answer.
You can put that in a httpd.conf or in the root .htaccess (but really consider removing all .htaccess, it's bad, it's slow, it's sad that you do not have access to the real configuration files).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With