0
votes

I dont know what is going on with the routes of my Laravel 7 project.

When the route is simple, like "admin", "users" or anything like "xxxxxx", it works well. But when I use the "/" for routes like "admin/", "admin/users", all the icons and images breaks.

I'm extending the views from the same blade layout.

Does anyone know what could it be?

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="shortcut icon" href="{{ asset('/back/assets/img/poker-chip.png') }}">

    title>Title | @yield('title')</title>

    <link href="{{mix('back/assets/css/bootstrap.css')}}" rel="stylesheet">
    <link href="back/assets/font-awesome/css/font-awesome.css" rel="stylesheet">

    @stack('styles')

    <link href="{{mix('back/assets/css/animate.css')}}" rel="stylesheet">
    <link href="{{mix('back/assets/css/style.css')}}" rel="stylesheet">

</head>

<img alt="image" class="rounded-circle" src="back/assets/img/a7.jpg">

Exemple: route 'admin', the image adress is http://localhost:8000/back/assets/img/a7.jpg. This is right!

route 'admin/', the image adress is http://localhost:8000/admin/back/assets/img/a7.jpg. This is wrong! There is an admin directory in the path that shouldn't be there.

2
In your html, the address for the image resources must be relative. Try using absolute address for images.Ahtsham Abbasi
Post your codessta

2 Answers

0
votes

Try changing a specific image from:

<img src="hello.jpg">

To

<img src="/hello.jpg">

Notice the / infront of the name. This should be the specific path to where the images are publicly store, examle: /images/source/hello.jpg

0
votes

try use concrete path instead of relative paths: change:

<img alt="image" class="rounded-circle" src="back/assets/img/a7.jpg">

to:

<img alt="image" class="rounded-circle" src="/back/assets/img/a7.jpg">