Redirect to external link in Laravel

0

How can I do to redirect out of my website in Laravel? I have already tried with Redirect :: away () but it did not. I saw some solutions with javascript but wanted to look for other ways.

    
asked by anonymous 06.03.2018 / 12:37

1 answer

2

According to the image inserted in the question, you can see that the $location->url value is "www.google.com".

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

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

  • Current URL: link
  • Added value without protocol: www.google.com
  • Final URL: link

If you add a slash at the beginning, without protocol, the browser understands that the value entered in the href property is relative to the domain:

  • Current URL: link
  • Domain: link
  • Value added without protocol and with slash: /www.google.com
  • Final URL: link

To resolve the issue, you must enter the desired protocol, for example, the https protocol:

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

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

    
06.03.2018 / 12:57