假设我有一个项目库存,由CodeIgniter编写。我面临的问题是:
在CodeIgniter 3.1.0中,<?php echo base_url(); ?>
返回的值为http://[::1]/inventory/
但旧版本的CodeIgniter(即:3.0.1)返回完整的基本路径(即:http://localhost/inventory)。
现在,我想在CodeIgniter 3.1.0中使用base_url()
返回完整的基本路径[ie :: http://localhost/inventory而不是http://[::1]/inventory/]
有谁能告诉我怎么能在CodeIgniter 3.1.0中做到这一点?
答案 0 :(得分:1)
打开application/config
目录,找到config.php
文件。现在$config['base_url'] = '';
将此更改为以下
$config['base_url'] = 'http://localhost/inventory/';
这在Codeigniter 3.1.0
中是强制性的答案 1 :(得分:1)
请在application / config / config.php
中查看您的基本网址从
改变$config['base_url'] = 'something';
到
$config['base_url'] = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';
$config['base_path'] = $_SERVER['DOCUMENT_ROOT'] . preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';
放置此内容后无需更改任何内容。如果您使用本地或现场主持人。