Laravel 5 找不到 http://localhost:8000/css/app.css

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35193467/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:10:44  来源:igfitidea点击:

Laravel 5 not find http://localhost:8000/css/app.css

phplaravellaravel-5blade

提问by Shoji Urashita

I am using Laravel 5 and got "Failed to load resource, the server responded with a status of 404(Not Found) http://localhost:8000/css/app.css"

我正在使用 Laravel 5 并得到“加载资源失败,服务器响应状态为 404(未找到)http://localhost:8000/css/app.css

If my layout.blade.php were

如果我的 layout.blade.php 是

   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

It works fine.

它工作正常。

But If I changed it to

但是如果我把它改成

 <link rel="stylesheet" href="{{ URL::asset('css/app.css') }}">

I got

我有

http://localhost:8000/css/app.cssFailed to load resource: the server responded with a status of 404 (Not Found)

http://localhost:8000/css/app.css加载资源失败:服务器响应状态为 404(未找到)

I have public/css/app.css which I got from gulp and it clearly exists these.

我有从 gulp 得到的 public/css/app.css,它显然存在这些。

If I entered http://localhost:8000/css/app.cssfrom browser URL, I got an error NotFoundHttpException in RouteCollection.php line 161:" because I do not write /css/app.css at routes.php.

如果我从浏览器 URL输入http://localhost:8000/css/app.css,我会在 RouteCollection.php 第 161 行收到错误 NotFoundHttpException:" 因为我没有在 routes.php 中写入 /css/app.css。

But I do not think this is a routing issue.

但我不认为这是路由问题。

I know very similiar issue in Stack Overflow but can not find specific solutions.

我知道 Stack Overflow 中有非常相似的问题,但找不到具体的解决方案。

回答by Shoji Urashita

I found a solution. There was no problem from the beginning.

我找到了解决办法。从一开始就没有问题。

The initial setting was correct.

初始设置是正确的。

<link rel="stylesheet" href="{{ URL::asset('css/app.css') }}">

The problem seems to be caused by Netbeans 8.1 embedded web server.

该问题似乎是由 Netbeans 8.1 嵌入式 Web 服务器引起的。

I was trying to test Windows 7 + Netbeans 8.1 embedded web server and always testing my program with http://xxx:8000/.

我试图测试 Windows 7 + Netbeans 8.1 嵌入式 Web 服务器,并且总是使用http://xxx:8000/测试我的程序。

The problem seems to be caused by Netbeans 8.1 embedded web server.

该问题似乎是由 Netbeans 8.1 嵌入式 Web 服务器引起的。

Now I am using Xampp embedded Apache and works perfect.

现在我使用 Xampp 嵌入式 Apache 并且工作完美。

回答by Gautam Patadiya

Try to load using this syntax

尝试使用此语法加载

{!! Html::style('css/all.css') !!}

in this case your all.css file located into public/css/all.css

在这种情况下,您的 all.css 文件位于 public/css/all.css