Redirect to external link in Laravel

Asked

Viewed 892 times

0

inserir a descrição da imagem aqui

How can I redirect out of my Laravel website? I tried it with Redirect::away() but it didn’t work. I saw some solutions with javascript but I wanted to look for other ways.

  • What is the content of $location->url?

  • @RFL www.google.pt

  • Eduardo, avoid putting code in images. Copy the code to the question.

1 answer

2


According to the image inserted in the question, it is possible to see that the value of $location->url is "www.google.pt".

The value does not contain the protocol, that is, it does not inform if the protocol is http, https, etc....

When this occurs, the browser understands that the value entered in the property href is relative to the current URL, i.e.:

If you add a bar at the beginning, with no protocol, the browser understands that the value entered in the property href is related to the field:

To resolve the issue, it is necessary to insert the desired protocol, for example the protocol https:

<small><a href="https://{{ $location->url }}" target="_blank">Url mapa</a><small>

However, if it is a dynamic system, the protocol should not be set in HTML, since it may be different for each URL.

  • That’s right, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.