Php htaccess:允许公众访问所有文件,但不允许访问文件夹

Php htaccess:允许公众访问所有文件,但不允许访问文件夹,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我的文件格式像 application - controllers - views etc... assetes - Images - Css etc... 和我的.htaccess文件如下: #Deny from all RewriteEngine on RewriteCond $1 !^(index\.php|assets|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] 我的

我的文件格式像

  application
       - controllers
       - views etc...
  assetes
       - Images
       - Css etc...
和我的.htaccess文件如下:

#Deny from all
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
我的问题是,资产文件夹访问每一个任何用户都可以查看所有图像和所有css文件,但需要的只是用户访问资产文件夹文件,而不是访问整个文件夹

请帮帮我
谢谢

在htaccess中使用以下行 重写cond%{REQUEST_FILENAME}-F 这是用于文件访问的

重写cond%{REQUEST_FILENAME}-D
这适用于口述访问

阻止目录访问,只需将
index.html
文件放入要阻止目录访问的文件夹即可

这是标准CodeIgniter安装的方式。可以在
application\controllers
文件夹中找到以下文件

<html>
<head>
    <title>403 Forbidden</title>
</head>
<body>
    <p>Directory access is forbidden.</p>
</body>
</html>

403禁止
目录访问被禁止


Order allow,deny
允许在
RewriteCond%{REQUEST_FILENAME}上从所有
重写引擎中执行-f
请使用以下代码RewriteCond%{REQUEST_FILENAME}更新您的.htaccess-d
重写规则^(.*)$index.php?/$1[L]