CodeIgniter不寻常的基础URL


CodeIgniter unusual base URL

我想将我的CodeIgniter安装的基础URL设置为localhost/ci/,并按照文档中的建议使用尾斜杠。

我试试这个:

$config['base_url'] = 'http://localhost/ci/';

和我的分页链接不是我所期望的。基本上,它们是坏的。

然而,我试着这样做:

$config['base_url'] = 'http://localhost/ci/index.php/';

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

和我的分页链接现在是好的。这是,

$config['base_url']    = 'http://localhost/ci/index.php/';

写基础URL的正确方法?

记住一件事…你的基础URL应该像

$config['base_url'] = 'http://localhost/ci/';

索引URL将是

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

那么你的网址就会变成

"http://localhost/ci/index.php"

如果你把索引URL设置为空,比如

$config['index_page'] = '';

那么你的网址将是

"http://localhost/ci/"

所以更好的在你的分页或任何地方你最好使用网站URL。您可以获得网站URL:

echo site_url();

网站URL将是基础URL和索引URL的组合:

site_url = base_url + index_url;