Understanding URLs and mage links

Posted 2 years ago by fsdolphin

This is a very basic question. Why does the route/URL affects the location of an image?

| ------------------------------------ 1 - Case ONE: -----------------------------------------|

This works fine image can be accessed...

Image Location:

public > images > my-image.png

Route:

Route::get('apps', function () {
    return view('apps');
});

View:

resources > views > apps.blade.php

    <img src="images/my-image.png" alt="">      

| ------------------------------------ 2 - Case TWO: -----------------------------------------|

This does NOT work, image CANNOT be accessed any more...

Image Location:

public > images > my-image.png

Route:

Route::get('apps/appName', function () {
 return view('appName');
});

View:

resources > views > appName.blade.php

    <img src="images/my-image.png" alt="">

In theory the only difference between the two cases is the URL. Can someone explain how does the URL affects the location of the image? I thought that the routs was just that a URL not the folder structure.

My point is that if in both cases the page appName.blade.php is in the same location and pointing to the same folder structure where the image resides why the second case doesn't work. Perhaps I don't understand how URLs work in general, sorry.

Please sign in or create an account to participate in this conversation.