2014年6月30日
Codeigniter 初始設定
設定預設的Controller
application/config/route.php
$route['default_controller'] = "welcome";
設定要自動load的library或model
application/config/autoload.php
$autoload['helper'] = array('url');
$autoload['libraries'] = array('database','session');
$autoload['model'] = array();
設定資料庫連結
application/config/database.php
設定自已要用的常數
application/config/constants.php
define('ROOT', str_replace('/application/config/constants.php', '', str_replace('\\', '/', __FILE__)));
設定.htaccess 移除index.php(記得apache的mod_rewrite要打開)
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
訂閱:
文章 (Atom)