VPS侦探论坛

 找回密码
 注册
查看: 7667|回复: 0

[Apache] apache和nginx下禁止访问txt文件

[复制链接]
发表于 2010-7-10 22:32:24 | 显示全部楼层 |阅读模式

如下是关于Apache和Nginx 限制该类事情办法:
Apache:解决办法;
<Directory "/home/domain/public_html">
  Options -Indexes   FollowSymLinks
  AllowOverride All
     <Files ~ ".txt">
        Order allow,deny
        Deny from all
    </Files>
</Directory>


Nginx:解决办法;
location ~* \.(txt|doc)$ {
               if (-f $request_filename) {
                  root /home/domain/public_html/test;
                  break;

                  }

               }


Nginx下请大家注意标点符号的使用,不要漏掉后面的“;”!

或者:
#location ~ /\.ht {
               #    deny  all;
               #} location ~* \.(txt|doc)${
         root /home/domain/public_html/test;
         deny all;
}
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-5-7 18:25 , Processed in 0.024925 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表