one simple question about defined('BASEPATH')
if (!defined('BASEPATH')) exit('No direct script access allowed');这句话 要不要 在每一个文件前面加? 哪些地方需要 RewriteEngine on
RewriteCond $1 !^(index\.php|resources|fckeditor)
RewriteRule ^(.*)$ /index.php/$1
既然我用 .htaccess 重写了 url,不以resources和fckeditor开头的 url 都会通过index.php来访问,index.php只会把请求转到各个controller,那么我只能通过controller来访问各个文件,这样就已经通过index.php解决了防止直接访问的问题,那还加 那句话不就 显得多余了? 嗯,没错,如果进行了 rewrite 就是有些多余,不过我认为这是一个好习惯,在各种情况下都不会导致代码被恶意执行。
并且,如果没有 rewrite 就有机会被恶意执行。
总之,写上是无害的。 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
但是这句代码执行的意思是? 本帖最后由 五点晨曦 于 2011-12-29 12:20 编辑
Ben 发表于 2011-12-29 10:14 static/image/common/back.gif
但是这句代码执行的意思是?
阻止直接访问你的model、controller、view等文件,保证只有index.php这个单一入口。
这句代码我已经加入了netbeans的新文件模板里面了 OK,感谢
页:
[1]