.htaccess - Make a directory invisible

后端 未结 3 753
夕颜
夕颜 2021-01-16 10:03

I have a .htaccess file that currently looks like:


    order allow,deny
    deny from all


Options All -Indexes
IndexIgnore         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-16 10:55

    1. You can use DirectorySlash Off to tell Apache to not to add trailing slash at the end of directories.

    2. Why use RewriteEngine On if you do not actually use rewrite engine (based on the code you have provided)? RedirectMatch has nothing to do with mod_rewrite.

    3. If you want to use mod_rewrite here, then try this rule -- it will return 404 code for /include folder (with and without trailing slash) as well as ANY resource inside that file (e.g. /include/main.php etc).

    RewriteEngine On
    
    RewriteRule ^include(/|/.+)?$ - [R=404,L]
    

提交回复
热议问题