拒绝访问文件
问题描述:
如何拒绝从外部访问一个文件?拒绝访问文件
if you go www.mysite.com/file.txt - ban.
if you go /home/public_html/file.txt - ok.
感谢;)
答
特定文件
<Files file.txt>
order allow,deny
deny from all
</Files>
所有扩展(.txt
)
<Files ~ "\.txt$">
Order allow,deny
Deny from all
</Files>
答
假设您使用的是Apache,您可以使用.htaccess文件来限制某些文件类型。
<FilesMatch "\.txt$">
Order Allow,Deny
Deny from all
</FilesMatch>
难道你不能把它放在文档根目录之外吗? – alexn 2011-03-09 13:21:27
'.exe'文件永远不会在浏览器中打开 – diEcho 2011-03-09 13:22:36
对不起,txt文件:) – lolalola 2011-03-09 13:23:19