0

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
  • 1
    In your html, the address for the image resources must be relative. Try using absolute address for images. Commented Jun 30, 2020 at 4:18
  • Post your codes Commented Jun 30, 2020 at 7:17

2 Answers 2

0

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">

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

Comments

0

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

1 Comment

Hi @Patrick, tanks for the answer bui it didn't work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.