CodeIgniter 設定個人首頁

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

設定

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

修改 application/config/routes.php

1
2
//將任何的名稱的 function 都重導至自定義的 index
$route['user/<strong>:any'</strong>] = "user/index";

增加 application/controllers/user.php

1
2
3
4
5
6
7
8
9
10
11
12
class User extends Controller { 
 
    function User()
    {
        parent::Controller();
    }
    function index()
    {
        // 取得網址上分段的資料
        echo $this->uri->segment(2);
    }
}

參考資料

Related Posts with Thumbnails

相關文章

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>