Skip to content
Advertisement

Why css and bootstrap is not loading in Laravel 5.3?

This is my route file…


    Route::group(['middleware' => ['auth']], function(){

        Route::get('/profile/{username}', 'ProfileControllers@getProfile');

    });

The “ProfileControllers” is this…


    namespace AppHttpControllers;
    use DB;
    use AppUser;
    use IlluminateHttpRequest;

    class ProfileControllers extends Controller
    {
        public function getProfile($username)
        {
            $user = DB::table('users')->where('username','=', $username)->get();
            return view('web.profile');
        }
    }

And this is the view file…


    @extends('layout')

    @section('content')
        This is your profile
    @stop

And The head of the Layout file is this…


    link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"
    link rel="stylesheet" type="text/css" href="css/app.css"

When I go to the url “localhost:8000/profile/username” and a ugly html without any css webpage is showing…. when I remove “/{username}” from route file, and make it “/profile/username” and go to the “localhost:8000/profile/username” (and also remove the $username part form controller) , then css and bootstrap loads perfectly….

What is happening here?

Advertisement

Answer

I fixed this issue by simply putting ‘/’ in front of the link

link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css"
link rel="stylesheet" type="text/css" href="/css/app.css"
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement