投稿 评论 顶部

thinkphp3.2----实现伪静态和路由配置

佚名 网络安全

URL模式:

0.普通? ?http://localhost/qixin/ThinkCMF(test)_backup/index.php?g=user&m=login&a=index    带有?号这种传参路径,对SEO不友好

1.pathinfo? ?http://localhost/qixin/ThinkCMF(test)_backup/index.php/user/login/index

2.rewrite? ? http://localhost/qixin/ThinkCMF(test)_backup/user/login/index.html          已经去除掉index.php,要开启Apache?rewrite moudle,建立.htaccess文件

?

在config中配置

'URL_ROUTER_ON'   => true,      // 开启路由'URL_MODEL'=>2, //URL模式'URL_ROUTE_RULES'=>array(    //'路由表达式' => '路由地址和传入参数'        'product'=>'Index/Index/product',        'articleList'=>'Index/Article/articleList',        '/^articleList_cat_id_(\d+)$/'=>'Index/Article/articleList?cat_id=:1',        '/^article_id_(\d+)$/'=>'Index/Article/detail?article_id=:1',
     'upload_face$' => 'user/profile/upload_face',       //规则路由 http://localhost/qixin/ThinkCMF(test)_backup/upload_face.html
     '/^upload_face_(\d+)$/' => 'user/profile/upload_face'  //正则路由 http://localhost/qixin/ThinkCMF(test)_backup/upload_face_1.html ),'URL_HTML_SUFFIX' => 'html', // URL伪静态后缀设置

?