I want to set external URL in some of my anchor tags but facing problem when URL is without http/https protocol. When URL is without these protocols URL become like following:
<a target="_blank" href="www.usatoday.com/"></a>
when I click on it or hover over it, it shows and redirect me to: http://localhost/event/www.usatoday.com
I've tried following two ways in href but didn't worked:
{{url($eventSponsorsRow->sponsorUrl)}}
{{ $eventSponsorsRow->sponsorUrl }}
instead of URL in href. Laravel 5.3
This is HTML and browser stuff, not Laravel/PHP itself.
You just need to provide protocol part of the url to make it external.
You can skip the http:
but it needs at least double slash in front of the url like:
<a target="_blank" href="//www.usatoday.com/"></a>
Please not, that if you skip the http(s):
part it will use currently used protocol.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With