close

不常從頭來過,所以也沒記住,只好筆記下來,也許再來看看。

從新開始安裝 CodeIgniter framework, 

  1. 當然是先下載 CodeIgniter
     
  2. 下載後解壓到網站根目錄或者重新命名為專案目錄,放哪兒自己想。
     
  3. ==修改設定 application/config/config.php ==
    1. 設定時區:看需求,我的空間設定為歐洲,所以自行改為台灣
      date_default_timezone_set('Asia/Taipei');
      $config['time_zone'] = date_default_timezone_get();
    2. 設定專案路徑:
      $config['base_url'] = '/專案目錄';
    3. 設定編碼:
      $config['charset'] = 'UTF-8';
    4. 自定義類前綴
      $config['subclass_prefix'] = 'MY_';
    5. 加密
      $config['encryption_key'] = '隨意輸入的一串長字串';
       
  4. ==建置 MY_Controller 共用檔案==
    1. 因為會共用程式、樣版,所以一起設置
    2. application/core/MY_Controller.php
       
  5. ==新增/.htaccess 隱藏 index.php ==
    1. 把 url 上的 index.php 隱藏起來
      <IfModule mod_rewrite.c>
          RewriteEngine on
          RewriteBase /
          RewriteCond $1 !^(index\.php|images|assets|css|robots\.txt|$)
          RewriteRule ^(.*)$ /專案目錄/index.php [L,QSA]
      </IfModule>
       
  6. ==修改 application/config/routes.php ==
    1. 網址不用再打首頁的 controller,比如原本有一個叫 welcome的把它刪了後,要指到另一個 controller
      例:首頁的 controller 為 index , 原本應輸入:http://abc.test.com/index
      在 routes 加上預設的 index 後,只要輸入:http://abc.test.com 即可。
    2. $route['default_controller'] = 'index'; // 首頁的 controller

 

設定完可以開工了!

 

arrow
arrow
    文章標籤
    codeigniter PHP
    全站熱搜

    Godspeed 發表在 痞客邦 留言(0) 人氣()