遨遊飛翔 | 學習筆記 For php、jQuery、MySql、Centos、Suse、Server

六月/09

1

CodeIgniter 設定個人首頁

這個是使用CodeIgniter的 URI 路由 以及 URI 类 來達成依不同使用者有自己的首頁。

設定:

假設網址為:http://www.shian.tw/user/shian

修改 application/config/routes.php

將任何的名稱的 function 都重導至自定義的 index
$route['user/:any'] = 『user/index』;

增加 application/controllers/user.php

class User extends Controller { 

    function User()
    {
        parent::Controller();
    }
    function index()
    {
        // 取得網址上分段的資料
        echo $this->uri->segment(2);
    }
}

參考資料:

http://codeigniter.org.cn/user_guide/general/routing.html
http://codeigniter.org.cn/user_guide/libraries/uri.html

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Hemidemi
  • Live
  • email
  • TwitThis
  • Twitter

相關文章

RSS Feed

仍無迴響。

Leave a comment!

<<

>>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Find it!

Theme Design by devolux.org