Codeigniter回显[:: 1]而不是localhost [英] Codeigniter echoing [::1] instead of localhost

查看:78
本文介绍了Codeigniter回显[:: 1]而不是localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CodeIgniter 3作为网络平台,并尝试将语义UI CSS导入到我的页面中.我是通过在CSS导入的href属性中使用CodeIgniter的base_url()方法来实现的.

I am using CodeIgniter 3 as a web platform and trying to import semantic-UI CSS into my page. I'm doing so by using CodeIgniter's base_url() method in the href property for the CSS import.

但是,semantic.css本身会导入服务器上存在的其他一些字体,由于跨域资源共享策略,这些字体随后无法加载.这是Chrome给我的错误消息:

However, semantic.css itself imports some other fonts present on my server, which are then unable to load because of Cross-Origin resource sharing policy. This is the error message chrome gives me:

起源"http://[::1]"的字体已被跨域资源共享策略阻止加载:在请求的资源上不存在"Access-Control-Allow-Origin"标头.因此,不允许访问来源" http://localhost ".

Font from origin 'http://[::1]' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

这是因为base_url()反映出域已经是[::1],而不是我在浏览器中键入的本地主机.

This is because base_url() echoes the domain has being [::1] and not localhost as I've typed into the browser.

出于某种原因,在我看来,chrome(以及Edge)没有将[::1]和localhost视为同一主机,或者也许我只是傻瓜.我所知道的是,如果我将mainsemantic.css文件和硬代码localhost的路径更改为该文件,它将起作用,并且如果我不是使用localhost请求我的页面,而是使用[::1]

For some reason, it appears to me that chrome (and also Edge) does not consider [::1] and localhost as the same host, or maybe I'm just being dumb. What I know though is that if I change the path of the main semantic.css file and hard code localhost into it, it works, and it also works if, instead of requesting my page using localhost, I use [::1]

我已经完成了其他与此项目非常相似的项目,但从未出现过此"[::1]".究竟是什么导致php回显了这样的路径?

I've done other projects very similar to this and never had this "[::1]" appear. What exactly is causing php to echo such a path ?

推荐答案

这是因为您的base_url为空.

config/config.php

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

关于 http://\[::1\]/

这篇关于Codeigniter回显[:: 1]而不是localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆