【发布时间】:2014-05-19 15:10:35
【问题描述】:
我有自定义 MVC 框架,我的 .htaccess 文件重写规则以通过 index.php 发送所有请求,然后路由请求。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(css|js|jpg|jpeg|JPG|gif|png|PNG|ico|pdf|swf|xml|pem)$ [NC]
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
问题是我在 index.php 和 .htaccess 所在的 public_html 文件夹中有一些 .txt 文件。是否可以不允许用户访问 .txt 文件?现在如果我访问www.MyURL/test.txt,我可以查看 txt 文件。但如果我这样做了www.MyURL/cont/action/param1 会正常工作。
【问题讨论】: