【ci框架】CI中site_url()和base_url()的区别

来源:互联网 发布:闻牛创富软件怎么样 编辑:程序博客网 时间:2024/05/21 22:57

在使用CI框架的使用经常碰到跳转和路径方面的问题,site_url()和base_url()很容易混淆,下面来说说他们的区别!

假如你config文件里面的base_url和index_page是这样定义的:

config['base_url'] = "http://domain.com/";

config['index_page'] = "index.php";

那么你若使用site_url("news/php/2");则实际url为

http://domain.com/index.php/news/php/2

若使用base_url("news/php/2");则url为:

http://domain.com/news/php2 

发现没有,base_url()少了一个index.php


注意:这两个函数在system/helpers/url_helper.php 文件中定义,这个文件属于系统的函数库文件


CI框架中做跳转的方法:

header("location:".site_url("common/login"));