Sinan Zikri
Sinan Zikri

Reputation: 91

Laravel is trying to find my public files in wrong directory when I use parameter in restful url

I'm trying to load a page using this laravel route:

Route::get('products/{category}', "ProductsController@index");

In the controller I return an oridnary view using blade and a master page. The problem is that the view can't load it's resources because it is trying to find them in a folder named "products".

localhost:8000/products/<and it is searching for the images and styles here instead the public folder>

do you have any idea how to solve this?

Upvotes: 0

Views: 1085

Answers (1)

codez
codez

Reputation: 1532

It is probably because you are not using absolute URLs to load your resources. You are probably doing something like:

<link rel="stylesheet" href="css/style.css">

What this will do is, that it will try to load the resource by appending css/style.css to the current URL.

For example:

If you are at: http://localhost/pages/home then, it may look for the resources at http://localhost/pages/css/style.css

Therefore the fix:

Use absolute URLs.

<link rel="stylesheet" href="http://localhost/css/style.css">

This should resolve your issue.

Upvotes: 2

Related Questions