我有自定义的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所在的public_html文件夹中有一些.txt文件.htaccess
。是否有可能不允许用户访问.txt文件?现在,如果我访问,www.MyURL/test.txt
我可以查看txt文件。但是,如果我这样做www.MyURL/cont/action/param1
会正常工作。
您可以.txt
使用以下命令阻止所有文件:
RewriteEngine on
RewriteRule \.txt$ - [F,NC]
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]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句