.htaccess deny files in subfolders

后端 未结 4 810
不思量自难忘°
不思量自难忘° 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条回答
  •  梦毁少年i
    2021-02-02 01:45

    You can only use file names in sections, not paths.

    There are three options I can see;

    • Put a .htaccess file in the same folder as the file.
    • Put the configuration in apache.conf using a directive and a directive. does not work in .htaccess files, only apache.conf
    • Create a rewrite rule using mod_rewrite a'la;

    -

    RewriteEngine on
    RewriteRule ^sub/folder/index.php$ http://yoursite/index.locked
    

    Will give a 404 on the file, if you want a permission denied, create a read protected file at the pointed to location.

提交回复
热议问题