3

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"

If my layout.blade.php were

   <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.css Failed to load resource: the server responded with a status of 404 (Not Found)

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

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

But I do not think this is a routing issue.

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

7
  • @Mr.Engineer He had mentioned in the question that css has been placed in public folder. Read question properly before making a comment. 1. Check permission for your public/css folder. 2. try to use url('public/css/app.css') or asset('css/app.css) Commented Feb 4, 2016 at 6:01
  • Ops. Sorry for mistake. Commented Feb 4, 2016 at 6:02
  • 1
    try href="{{ URL::asset('public/css/app.css') }}"> if it doesn't work it is a file permision error Commented Feb 4, 2016 at 6:05
  • 1
    I was able to access my file in the public folder by going to localhost:8000/css/app.css . This does not need to be included in the routes. Check properly being generated correctly by gulp. Or just try to put a dummy css file in the /css directory and check if that works. Commented Feb 4, 2016 at 7:19
  • 1
    Also try @madalinivascu solution but with the attribute type="text/css" in your link tag. Commented Feb 4, 2016 at 7:21

2 Answers 2

1

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.

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

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

Now I am using Xampp embedded Apache and works perfect.

Sign up to request clarification or add additional context in comments.

Comments

0

Try to load using this syntax

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.