這章主要介紹一下在開發前期CI一些比較通常的做法。
【一般準備】
先在application/config/autoload.php(當時第92行)做一些配置:
`$autoload['helper'] = array('url','form');`
和application/config/config.php(當時第26行):
`$config['base_url'] = 'http://www.localhost/CI/hrmsreport/';`
和application/config/routes.php(當時第52行):
`$route['default_controller'] = 'Login';`
這樣使用`base_url()`函數就可以在`http://www.localhost/CI/hrmsreport/`域名下,將控制器默認設為`Login`,默認加載`'url','form'`這兩個函數功能。
加載CSS和JS文件可以這樣寫:
~~~
<link rel="stylesheet" href="<?php echo base_url('resources/css/materia-bootstrap.css'); ?>"/>
<link rel="stylesheet" href="<?php echo base_url() ?>resources/css/style.css"/>
~~~
【設置.hatccess】:
~~~
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]
~~~
這樣可以直接省略index.php訪問了:
