Apache 不在远程浏览器上加载 CSS 文件,但在本地主机上工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2304029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache not loading CSS files on remote browsers but works on localhost
提问by user269959
I have an ubuntu installation on my laptop i use for web app development. When i type in http://localhost/blah.phpi see my php web page as i normally would with all css style loaded and rendering fine.
我的笔记本电脑上安装了 ubuntu,用于 Web 应用程序开发。当我输入http://localhost/blah.php 时,我会像往常一样看到我的 php 网页,所有 css 样式都已加载并呈现正常。
When i try to connect to this same apache server from a remote machine by typing in the IP address the page loads but without any css styling at all. I also get the same problem trying to connect to the apache server from a virtual machine on the same box. I would like to get this working so i can test my web apps in IE but obviously css not loading is a problem. Any tips ?
当我尝试通过输入 IP 地址从远程机器连接到同一个 apache 服务器时,页面加载但根本没有任何 css 样式。尝试从同一台机器上的虚拟机连接到 apache 服务器时,我也遇到了同样的问题。我想让这个工作,所以我可以在 IE 中测试我的网络应用程序,但显然 css 未加载是一个问题。有小费吗 ?
采纳答案by Pekka
Look into your source code and look how your style sheets are referenced.
查看您的源代码并查看您的样式表是如何被引用的。
If you have references to http://localhost/mystylesheet.css, that's your problem right there.
如果您有对 的引用http://localhost/mystylesheet.css,那就是您的问题。
If that doesn't help, try to access a style sheet directly (enter the address in the browser) and tell us what happens. Also post the URL you are using. The head of the HTML document you are calling would also be helpful.
如果这没有帮助,请尝试直接访问样式表(在浏览器中输入地址)并告诉我们会发生什么。同时发布您正在使用的 URL。您正在调用的 HTML 文档的头部也会有所帮助。

