Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess拒绝所有-->;directoryindex不工作(拒绝所有白名单文件)_Apache_.htaccess - Fatal编程技术网

Apache .htaccess拒绝所有-->;directoryindex不工作(拒绝所有白名单文件)

Apache .htaccess拒绝所有-->;directoryindex不工作(拒绝所有白名单文件),apache,.htaccess,Apache,.htaccess,我想拒绝访问服务器上的所有文件和目录,但有几个是我明确允许的。如何使用.htaccess实现这一点?为什么我的方法不起作用?我知道我必须允许.css、.jpg等 DirectoryIndex index.html Order Deny,Allow Deny from all Allow from 127.0.0.1 <Files index.html> order Allow,Deny Allow from all </Files> DirectoryInd

我想拒绝访问服务器上的所有文件和目录,但有几个是我明确允许的。如何使用.htaccess实现这一点?为什么我的方法不起作用?我知道我必须允许.css、.jpg等

DirectoryIndex index.html

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

<Files index.html>
  order Allow,Deny
  Allow from all
</Files>
DirectoryIndex.html
命令拒绝,允许
全盘否定
允许从127.0.0.1开始
命令允许,拒绝
通融
编辑:当我尝试访问index.html时,上面的.htaccess给了我一个“禁止”错误。为什么?

编辑:这似乎很管用。我希望没有留下任何漏洞:

#Disallow everything
<filesmatch "\.+">
    Order Allow,Deny
    Deny from all
</filesmatch> 

#Allow index
<Files index.html>
  order Allow,Deny
  Allow from all
</Files>

#Allow peripheral files
<FilesMatch "\.(css|png|jpg|js|ico)$">
    Order Allow,Deny
    Allow from all
</FilesMatch>
#禁止一切
命令允许,拒绝
全盘否定
#允许索引
命令允许,拒绝
通融
#允许外围文件
命令允许,拒绝
通融

IP地址:
127.0.0.1
有权访问您的服务器,其他人无权访问。
本部分:

<Files index.html>
  order Allow,Deny
  Allow from all
</Files>

第一条指令应为
<代码>“\.+”仅匹配包含点的文件,但允许不包含点的文件。
 <FilesMatch      !"(01\.jpe?g|01\.html|xml)$"> 
  order Allow,Deny
  allow from 127.0.0.1


</FilesMatch>