961900940 发表于 2016-4-18 23:41:14

site_url 生成URL的问题

本地搭的CI框架,加载了一下URL辅助函数,本地链接访问:http://localhost/CodeIgniter-3.0.6/index.php/Index/index    打印site_url生成的链接:http://127.0.0.1/CodeIgniter-3.0.6/index.php/Index/index2(有时会是http://[::1]/CodeIgniter-3.0.6/index.php/Index/index2)导致ajax时有跨域的问题,如果访问链接是http://127.0.0.1/CodeIgniter-3.0.6/index.php/Index/index   就不会有问题,怎么解决?

ZBill 发表于 2016-4-25 19:44:13

我的base_url也出现这个问题了,找不到解决方法

yw86 发表于 2016-4-26 14:01:21

我也遇到同样的问题site_url()生成http://[::1]/而不是localhost,不知道是什么原因造成的

ty0716 发表于 2016-4-27 13:55:34

$config['base_url'] = is_cli() ? '' : 'http://' . $_SERVER['HTTP_HOST'] . '/';

shanyq 发表于 2016-5-17 21:30:37

设置base_url为“http://localhost/CodeIgniter-3.0.6/”之类的.....
这样是可以运行的,不知道对不对

combook 发表于 2016-5-24 11:27:01

修改核心文件内system/core/config.php的SERVER_ADD为HTTP_HOST即可返回localhost

geek_kk 发表于 2018-4-13 14:20:59

{:1_1:}同样遇到了问题,有人解释一下吗?
<a href="http://[::1]/index.php/news/hello slug!">View article</a>

geek_kk 发表于 2018-4-13 14:22:09

combook 发表于 2016-5-24 11:27
修改核心文件内system/core/config.php的SERVER_ADD为HTTP_HOST即可返回localhost

为什么会产生这个问题呢?

Hex 发表于 2018-4-14 22:33:17

geek_kk 发表于 2018-4-13 14:20
同样遇到了问题,有人解释一下吗?
View article

你需要去设置 site_url 这个配置项,CI 唯一需要配置的地方。
页: [1]
查看完整版本: site_url 生成URL的问题