我有以下.htaccess文件:如何拒绝访问文件在.htaccess
RewriteEngine On
RewriteBase/
# Protect the htaccess file
<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>
# Protect log.txt
<Files ./inscription/log.txt>
Order Allow,Deny
Deny from all
</Files>
# Disable directory browsing
Options All -Indexes
我试图禁止游客进入下列文件:
domain.com/inscription/log.txt
但我以上不起作用:我仍然可以从浏览器远程访问文件。
如果您使用的是IIS,在web.config文件中做到这一点,而不是。 – 2014-11-03 16:33:09
使用重写规则会拒绝我自己的代码访问* .txt的内容。你如何解决这个问题? – Pantss 2015-12-06 05:34:53
“''指令的范围仅适用于该目录” - 否则不适用。它适用于该目录_and_下面的所有子目录。所以''文件“log.txt”>'会抓住'/ log.txt' _and_'/inscription/log.txt'。 –
MrWhite
2017-01-30 15:45:13