.htaccess deny files in subfolders

后端 未结 4 807
不思量自难忘°
不思量自难忘° 2021-02-02 01:33

I want to block access to \"sub/folder/index.php\", but not \"index.php\" anywhere else.


    Order allow,deny
    Deny from all
         


        
4条回答
  •  一生所求
    2021-02-02 01:52

    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).

提交回复
热议问题