在使用CI框架的使用常常碰到跳轉和路徑方面的問題,site_url()和base_url()很容易混淆,下面來講說他們的區別!php
假如你config文件裏面的base_url和index_page是這樣定義的:框架
config['base_url'] = "http://domain.com/";dom
config['index_page'] = "index.php";url
那麼你若使用site_url("news/php/2");則實際url爲spa
http://domain.com/index.php/news/php/2it
若使用base_url("news/php/2");則url爲:margin
http://domain.com/news/php2 di
發現沒有,base_url()少了一個index.php文件