ThinkPHP小结
1.重写 去除index.php
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
伪静态 config.php
//'配置项'=>'配置值'
'URL_MODEL'=>2,
'URL_PATHINFO_DEPR'=>'-',
示例 : http://www.myapp.im/User-UserInfo-uid-2
2.路由
config.php
//ThinkPHP支持URL路由功能,要启用路由功能,需要设置URL_ROUTER_ON 参数为true
'URL_ROUTER_ON'=>true,
//路由定义
'URL_ROUTE_RULES'=> array(
//'blog/:year\d/:month\d'=>'Blog/archive', //规则路由
//'User/:uid\d'=>'User/Userinfo', //规则路由
//'blog/:cate'=>'Blog/category', //规则路由
'/^User\/(\d+)/' => 'User/Userinfo?uid=:1',//正则路由
'/^User\/(\w+)/' => 'User/Nameinfo?name=:1',//正则路由
),
示例 : http://www.myapp.im/User-666
3.url大小写
'URL_CASE_INSENSITIVE' =>true
就可以实现URL访问不再区分大小写了。http://serverName/index.php/User/add//将等效于 http://serverName/index.php/user/add
4.database
return array(
‘DB_TYPE’=> ‘mysql’,
‘DB_HOST’=> ‘localhost’,
‘DB_NAME’=>’thinkphp’,
‘DB_USER’=>’root’,
‘DB_PWD’=>”,
‘DB_PORT’=>’3306′,
‘DB_PREFIX’=>’think_’,
// 其他项目配置参数………
);